From 9c4eb8f1f4fb5ed20751d3f458b8c3fb10fbc2e6 Mon Sep 17 00:00:00 2001 From: jotacemarin Date: Fri, 9 Feb 2024 11:59:51 -0500 Subject: [PATCH] rename dev pipeline, add workflow to prod --- .../cd-prod-botnorrea-v2-telegram.yml | 64 +++++++++++++++++++ ...y.yml => ci-dev-botnorrea-v2-telegram.yml} | 0 2 files changed, 64 insertions(+) create mode 100644 .github/workflows/cd-prod-botnorrea-v2-telegram.yml rename .github/workflows/{ci-dev-botnorrea-v2-telegram copy.yml => ci-dev-botnorrea-v2-telegram.yml} (100%) diff --git a/.github/workflows/cd-prod-botnorrea-v2-telegram.yml b/.github/workflows/cd-prod-botnorrea-v2-telegram.yml new file mode 100644 index 0000000..16d02a8 --- /dev/null +++ b/.github/workflows/cd-prod-botnorrea-v2-telegram.yml @@ -0,0 +1,64 @@ +name: cd-dev-botnorrea-v2-telegram + +on: + push: + branches: [master] + +jobs: + unit-test: + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: ["18.x"] + + steps: + - uses: actions/checkout@v3 + + # Obtener el nombre del autor del commit + - name: Get commit author + run: | + author=$(git log -1 --format='%an') + echo "author=$author" + + # Create new git tag + - name: Create new git tag + if: ${{ author != '${{ secrets.BOTNORREA_V2_NAME }}' }} + run: | + git config --global user.email "${{ secrets.BOTNORREA_V2_EMAIL }}" + git config --global user.name "${{ secrets.BOTNORREA_V2_NAME }}" + git tag -a "v$(npm run version)" -m "Deploy by ${{ secrets.BOTNORREA_V2_NAME }}" + git push origin master "v$(npm run version)" + + # Deploy to production + - name: Using Node.js ${{ matrix.node-version }} + if: ${{ author == '${{ secrets.BOTNORREA_V2_NAME }}' }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + + - name: Install dependencies + if: ${{ author == '${{ secrets.BOTNORREA_V2_NAME }}' }} + run: | + npm install -g serverless + npm i + + - name: Create JSON + if: ${{ author == '${{ secrets.BOTNORREA_V2_NAME }}' }} + id: create-json + uses: jsdaniell/create-json@v1.2.3 + with: + name: "dev.json" + json: ${{ secrets.CONFIG_FILE_PROD }} + dir: "config/" + + - name: Setup credentials + if: ${{ author == '${{ secrets.BOTNORREA_V2_NAME }}' }} + run: serverless config credentials --provider aws --key ${{ secrets.KEY_ID }} --secret ${{ secrets.SECRET_ACCESS_KEY }} --profile ${{ secrets.PROFILE }} + + - name: Deploy + if: ${{ author == '${{ secrets.BOTNORREA_V2_NAME }}' }} + run: npm run prod:deploy + env: + AWS_ACCESS_KEY_ID: ${{ secrets.KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.SECRET_ACCESS_KEY }} diff --git a/.github/workflows/ci-dev-botnorrea-v2-telegram copy.yml b/.github/workflows/ci-dev-botnorrea-v2-telegram.yml similarity index 100% rename from .github/workflows/ci-dev-botnorrea-v2-telegram copy.yml rename to .github/workflows/ci-dev-botnorrea-v2-telegram.yml