From 8c1163c9d1264f21a13e96f3442a71134b16dd2c Mon Sep 17 00:00:00 2001 From: leandro Date: Fri, 10 Feb 2023 15:29:52 -0300 Subject: [PATCH 01/44] adding static web in s3 workflows templates --- .../github/web-s3-develop-push-cicd.yml | 46 +++++++++++++++ .../github/web-s3-hotfix-push-cicd.yml | 53 +++++++++++++++++ .../github/web-s3-master-push-cicd.yml | 55 +++++++++++++++++ ...web-s3-realease-production-deploy-cicd.yml | 59 +++++++++++++++++++ .../github/web-s3-testing-deploy-cicd.yml | 53 +++++++++++++++++ .github/workflows/web-s3-create-tag.yml | 42 +++++++++++++ .github/workflows/web-s3-generate-pr.yml | 38 ++++++++++++ .github/workflows/web-s3-validate.yml | 26 ++++++++ 8 files changed, 372 insertions(+) create mode 100644 .github/web/static-s3/github/web-s3-develop-push-cicd.yml create mode 100644 .github/web/static-s3/github/web-s3-hotfix-push-cicd.yml create mode 100644 .github/web/static-s3/github/web-s3-master-push-cicd.yml create mode 100644 .github/web/static-s3/github/web-s3-realease-production-deploy-cicd.yml create mode 100644 .github/web/static-s3/github/web-s3-testing-deploy-cicd.yml create mode 100644 .github/workflows/web-s3-create-tag.yml create mode 100644 .github/workflows/web-s3-generate-pr.yml create mode 100644 .github/workflows/web-s3-validate.yml diff --git a/.github/web/static-s3/github/web-s3-develop-push-cicd.yml b/.github/web/static-s3/github/web-s3-develop-push-cicd.yml new file mode 100644 index 0000000..3f786a7 --- /dev/null +++ b/.github/web/static-s3/github/web-s3-develop-push-cicd.yml @@ -0,0 +1,46 @@ +name: Push in development branch +run-name: > + "Create PR FROM develop TO ${{ vars.DESTINATION_PR_ON_DEVELOP_WORKFLOW }}: ${{ github.event.head_commit.message }}" + +on: + push: + branches: + - develop + + +jobs: + testing: + uses: ./.github/workflows/web-s3-validate.yml + with: + node-version: ${{ vars.NODE_VERSION }} + + build: + needs: [ testing ] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: ${{ vars.NODE_VERSION }} + - run: npm ci + - run: npm run release + + + generate-pr: + needs: [build] + uses: ./.github/workflows/web-s3-generate-pr.yml + with: + destination-branch-name: ${{ vars.DESTINATION_PR_ON_DEVELOP_WORKFLOW }} + pr-title: "Pushing develop into ${{ vars.DESTINATION_PR_ON_DEVELOP_WORKFLOW }}" + + notify: + if: ${{ always() }} + needs: [testing, build, generate-pr] + runs-on: ubuntu-latest + steps: + - name: Notify Slack + uses: steplix/cicd-notify@0.0.17 + with: + template: 'push' + status: ${{ needs.testing.result || needs.build.result || needs.generate-pr.result }} + slack_webhook_url: ${{ secrets.SLACK_WEBHOOK }} \ No newline at end of file diff --git a/.github/web/static-s3/github/web-s3-hotfix-push-cicd.yml b/.github/web/static-s3/github/web-s3-hotfix-push-cicd.yml new file mode 100644 index 0000000..5ec674e --- /dev/null +++ b/.github/web/static-s3/github/web-s3-hotfix-push-cicd.yml @@ -0,0 +1,53 @@ +name: Push Hotfix in master branch +run-name: > + Push: ${{ github.ref_name }} + +on: + push: + branches: + - 'hotfix/**' + + +jobs: + + testing: + uses: ./.github/workflows/web-s3-validate.yml + with: + node-version: ${{ vars.NODE_VERSION }} + + build: + needs: [ testing ] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: ${{ vars.NODE_VERSION }} + - run: npm ci + - run: npm run release + + generate-pr-to-master: + needs: [testing,build] + uses: ./.github/workflows/web-s3-generate-pr.yml + with: + destination-branch-name: ${{ vars.DESTINATION_PR_ON_TESTING_WORKFLOW }} + pr-title: " is TAG VERSION INCREMENT: Pushing HOTFIX ${{ github.ref_name }} into Master" + + generate-pr-to-develop: + needs: [testing,build] + uses: ./.github/workflows/web-s3-generate-pr.yml + with: + destination-branch-name: ${{ vars.DESTINATION_PR_ON_DEVELOP_WORKFLOW }} + pr-title: "Pushing HOTFIX ${{ github.ref_name }} into Develop" + + notify: + if: ${{ always() }} + needs: [ testing,build,generate-pr-to-master,generate-pr-to-develop ] + runs-on: ubuntu-latest + steps: + - name: Notify Slack + uses: steplix/cicd-notify@0.0.17 + with: + template: 'push' + status: ${{ needs.testing.result || needs.build.result || needs.generate-pr-to-master.result || needs.generate-pr-to-develop.result }} + slack_webhook_url: ${{ secrets.SLACK_WEBHOOK }} \ No newline at end of file diff --git a/.github/web/static-s3/github/web-s3-master-push-cicd.yml b/.github/web/static-s3/github/web-s3-master-push-cicd.yml new file mode 100644 index 0000000..eb1b012 --- /dev/null +++ b/.github/web/static-s3/github/web-s3-master-push-cicd.yml @@ -0,0 +1,55 @@ +name: Push in master branch +run-name: > + ${{ github.event.pull_request.title }} + +on: + push: + branches: + - master + + +jobs: + + tagging: + if: github.event.pull_request.merged == true + uses: ./.github/workflows/web-s3-create-tag.yml + with: + text-where-search-for-parameters: ${{ github.event.pull_request.title }} + + build-zip-upload: + needs: [ tagging ] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: ${{ vars.NODE_VERSION }} + - run: npm ci + - run: npm run release + #ZIP + - name: generate-zip + id: zip + run: cd out && tar -czvf ${{ needs.tagging.outputs.tag }}.tar.gz * + + #UPLOAD + - uses: aws-actions/configure-aws-credentials@v1.7.0 + with: + aws-access-key-id: ${{ secrets.PROD_AWS_KEY_ID }} + aws-secret-access-key: ${{ secrets.PROD_AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ secrets.PROD_AWS_REGION }} + - name: copy files to S3 + run: | + aws s3 cp out/${{ needs.tagging.outputs.tag }}.tar.gz s3://${{ vars.PROD_AWS_BUCKET_ARTIFACT }}/${{ needs.tagging.outputs.tag }}.tar.gz + + + notify: + if: ${{ always() }} + needs: [ tagging,build-zip-upload ] + runs-on: ubuntu-latest + steps: + - name: Notify Slack + uses: steplix/cicd-notify@0.0.17 + with: + template: 'push' + status: ${{ needs.tagging.result || needs.build-zip-upload.result }} + slack_webhook_url: ${{ secrets.SLACK_WEBHOOK }} \ No newline at end of file diff --git a/.github/web/static-s3/github/web-s3-realease-production-deploy-cicd.yml b/.github/web/static-s3/github/web-s3-realease-production-deploy-cicd.yml new file mode 100644 index 0000000..60f0e8b --- /dev/null +++ b/.github/web/static-s3/github/web-s3-realease-production-deploy-cicd.yml @@ -0,0 +1,59 @@ +name: Deployment to production +run-name: > + Production deployment ${{ github.event.release.tag_name }}: ${{ github.event.release.name }} +on: + release: + types: [published] + + +jobs: + + ## DEPLOY + + download_unzip_deploy: + runs-on: ubuntu-latest + steps: + #DOWNLOAD + - uses: aws-actions/configure-aws-credentials@v1.7.0 + with: + aws-access-key-id: ${{ secrets.PROD_AWS_KEY_ID }} + aws-secret-access-key: ${{ secrets.PROD_AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ secrets.PROD_AWS_REGION }} + + - name: download zip from S3 + run: | + aws s3 cp s3://${{ vars.PROD_AWS_BUCKET_ARTIFACT }}/${{ github.event.release.tag_name }}.tar.gz . + #UNZIP + - name: mkdir + run: mkdir output + + - name: un-zip + id: unzip + run: tar -xvzf ${{ github.event.release.tag_name }}.tar.gz -C output + + #UPLOAD + - uses: aws-actions/configure-aws-credentials@v1.7.0 + with: + aws-access-key-id: ${{ secrets.PROD_AWS_KEY_ID }} + aws-secret-access-key: ${{ secrets.PROD_AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ secrets.PROD_AWS_REGION }} + - name: copy files to S3 + run: | + aws s3 sync output s3://${{ vars.PROD_AWS_BUCKET }} + - name: Cloudfront invalidation + run: | + aws cloudfront create-invalidation --distribution-id ${{ vars.PROD_AWS_CLOUDFRONT_DISTRIBUTION_ID }} --paths "/*" + + + + notify: + if: ${{ always() }} + needs: [ download_unzip_deploy ] + runs-on: ubuntu-latest + steps: + - name: Notify Slack + uses: steplix/cicd-notify@0.0.17 + with: + template: 'push' + status: ${{ needs.download_unzip_deploy.result}} + slack_webhook_url: ${{ secrets.SLACK_WEBHOOK }} \ No newline at end of file diff --git a/.github/web/static-s3/github/web-s3-testing-deploy-cicd.yml b/.github/web/static-s3/github/web-s3-testing-deploy-cicd.yml new file mode 100644 index 0000000..012e51c --- /dev/null +++ b/.github/web/static-s3/github/web-s3-testing-deploy-cicd.yml @@ -0,0 +1,53 @@ +name: Push in testing branch +run-name: > + "Deploying testing and creating PR to ${{ vars.DESTINATION_PR_ON_TESTING_WORKFLOW }}" +on: + push: + branches: + - testing + + +jobs: + + build_deploy: + runs-on: ubuntu-latest + steps: + #BUILD + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: ${{ vars.NODE_VERSION }} + - run: npm ci + - run: npm run release + #UPLOAD + - uses: aws-actions/configure-aws-credentials@v1.7.0 + with: + aws-access-key-id: ${{ secrets.TEST_AWS_KEY_ID }} + aws-secret-access-key: ${{ secrets.TEST_AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ secrets.TEST_AWS_REGION }} + - name: copy files to S3 + run: | + aws s3 sync out s3://${{ vars.TEST_AWS_BUCKET }} + - name: Cloudfront invalidation + run: | + aws cloudfront create-invalidation --distribution-id ${{ vars.TEST_AWS_CLOUDFRONT_DISTRIBUTION_ID }} --paths "/*" + + + generate-pr: + needs: build_deploy + uses: ./.github/workflows/web-s3-generate-pr.yml + with: + destination-branch-name: ${{ vars.DESTINATION_PR_ON_TESTING_WORKFLOW }} + pr-title: " is TAG VERSION INCREMENT: PUSHING testing INTO ${{ vars.DESTINATION_PR_ON_TESTING_WORKFLOW }}" + + notify: + if: ${{ always() }} + needs: [ build_deploy,generate-pr ] + runs-on: ubuntu-latest + steps: + - name: Notify Slack + uses: steplix/cicd-notify@0.0.17 + with: + template: 'push' + status: ${{ needs.build_deploy.result || needs.generate-pr.result }} + slack_webhook_url: ${{ secrets.SLACK_WEBHOOK }} \ No newline at end of file diff --git a/.github/workflows/web-s3-create-tag.yml b/.github/workflows/web-s3-create-tag.yml new file mode 100644 index 0000000..71abdd4 --- /dev/null +++ b/.github/workflows/web-s3-create-tag.yml @@ -0,0 +1,42 @@ +name: Create TAG + +on: + workflow_call: + inputs: + text-where-search-for-parameters: + type: string + description: 'Message to parse. Defaults to head commit message' + required: false + default: ${{ github.event.head_commit.message }} + outputs: + tag: + description: "The tag created" + value: ${{ jobs.tagging.outputs.tag }} + +jobs: + + ### Running the TAG creation + + tagging: + runs-on: ubuntu-latest + outputs: + tag: ${{ steps.bumped_tag.outputs.version }} + steps: + - uses: steplix/cicd-check-parameter@1.0.0 + id: args + with: + message: ${{ inputs.text-where-search-for-parameters}} + param-0: major + param-1: minor + + - name: Get bumping mode + id: bump-mode + run: echo "mode=${{ (steps.args.outputs.param-0 == 'true' && 'major') || (steps.args.outputs.param-1 == 'true' && 'minor') || 'patch' }}" >> $GITHUB_OUTPUT + + # Bump tag without affecting repository + - uses: zwaldowski/semver-release-action@v3 + name: Get bumped tag + id: bumped_tag + with: + bump: ${{ steps.bump-mode.outputs.mode }} + github_token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/web-s3-generate-pr.yml b/.github/workflows/web-s3-generate-pr.yml new file mode 100644 index 0000000..c47f671 --- /dev/null +++ b/.github/workflows/web-s3-generate-pr.yml @@ -0,0 +1,38 @@ +name: generate pr + +on: + workflow_call: + inputs: + origin-branch-name: + type: string + description: "Name of the branch of origin from which the pr starts. If blank, default: triggered branch" + default: "" + required: false + destination-branch-name: + type: string + description: "Destination branch name for the pr" + required: true + pr-title: + type: string + description: "Title for the pr" + default: "An automated PR" + required: false + + + +jobs: + + ### Generating PR + + generate-pr: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: generate-pr + id: open-pr + uses: repo-sync/pull-request@v2 + with: + source_branch: ${{ inputs.origin-branch-name }} + destination_branch: ${{ inputs.destination-branch-name }} + pr_title: ${{ inputs.pr-title }} + - run: echo "PR GENERATED SUCCESSFULLY" \ No newline at end of file diff --git a/.github/workflows/web-s3-validate.yml b/.github/workflows/web-s3-validate.yml new file mode 100644 index 0000000..ea53a4a --- /dev/null +++ b/.github/workflows/web-s3-validate.yml @@ -0,0 +1,26 @@ +name: Test + +on: + workflow_call: + inputs: + node-version: + description: 'Node version to use' + type: string + default: 14.18.0 + required: false + +jobs: + + ### Running the Test + + verify: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: ${{ inputs.node-version }} + - run: npm ci + - run: npm run lint --if-present + - run: npm run test --if-present + - run: echo "TEST SUCCESSFULLY" From d1ac623a10ab618a57733142e4caaed092bed135 Mon Sep 17 00:00:00 2001 From: leandro Date: Fri, 10 Feb 2023 16:10:06 -0300 Subject: [PATCH 02/44] change reference to reposiory --- .github/web/static-s3/github/web-s3-develop-push-cicd.yml | 4 ++-- .github/web/static-s3/github/web-s3-hotfix-push-cicd.yml | 6 +++--- .github/web/static-s3/github/web-s3-master-push-cicd.yml | 2 +- .github/web/static-s3/github/web-s3-testing-deploy-cicd.yml | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/web/static-s3/github/web-s3-develop-push-cicd.yml b/.github/web/static-s3/github/web-s3-develop-push-cicd.yml index 3f786a7..7e6aa74 100644 --- a/.github/web/static-s3/github/web-s3-develop-push-cicd.yml +++ b/.github/web/static-s3/github/web-s3-develop-push-cicd.yml @@ -10,7 +10,7 @@ on: jobs: testing: - uses: ./.github/workflows/web-s3-validate.yml + uses: steplix/cicd-steplix/.github/workflows/web-s3-validate.yml@main with: node-version: ${{ vars.NODE_VERSION }} @@ -28,7 +28,7 @@ jobs: generate-pr: needs: [build] - uses: ./.github/workflows/web-s3-generate-pr.yml + uses: steplix/cicd-steplix/.github/workflows/web-s3-generate-pr.yml@main with: destination-branch-name: ${{ vars.DESTINATION_PR_ON_DEVELOP_WORKFLOW }} pr-title: "Pushing develop into ${{ vars.DESTINATION_PR_ON_DEVELOP_WORKFLOW }}" diff --git a/.github/web/static-s3/github/web-s3-hotfix-push-cicd.yml b/.github/web/static-s3/github/web-s3-hotfix-push-cicd.yml index 5ec674e..2a8d117 100644 --- a/.github/web/static-s3/github/web-s3-hotfix-push-cicd.yml +++ b/.github/web/static-s3/github/web-s3-hotfix-push-cicd.yml @@ -11,7 +11,7 @@ on: jobs: testing: - uses: ./.github/workflows/web-s3-validate.yml + uses: steplix/cicd-steplix/.github/workflows/web-s3-validate.yml@main with: node-version: ${{ vars.NODE_VERSION }} @@ -28,14 +28,14 @@ jobs: generate-pr-to-master: needs: [testing,build] - uses: ./.github/workflows/web-s3-generate-pr.yml + uses: steplix/cicd-steplix/.github/workflows/web-s3-generate-pr.yml@main with: destination-branch-name: ${{ vars.DESTINATION_PR_ON_TESTING_WORKFLOW }} pr-title: " is TAG VERSION INCREMENT: Pushing HOTFIX ${{ github.ref_name }} into Master" generate-pr-to-develop: needs: [testing,build] - uses: ./.github/workflows/web-s3-generate-pr.yml + uses: steplix/cicd-steplix/.github/workflows/web-s3-generate-pr.yml@main with: destination-branch-name: ${{ vars.DESTINATION_PR_ON_DEVELOP_WORKFLOW }} pr-title: "Pushing HOTFIX ${{ github.ref_name }} into Develop" diff --git a/.github/web/static-s3/github/web-s3-master-push-cicd.yml b/.github/web/static-s3/github/web-s3-master-push-cicd.yml index eb1b012..d25acbc 100644 --- a/.github/web/static-s3/github/web-s3-master-push-cicd.yml +++ b/.github/web/static-s3/github/web-s3-master-push-cicd.yml @@ -12,7 +12,7 @@ jobs: tagging: if: github.event.pull_request.merged == true - uses: ./.github/workflows/web-s3-create-tag.yml + uses: steplix/cicd-steplix/.github/workflows/web-s3-create-tag.yml@main with: text-where-search-for-parameters: ${{ github.event.pull_request.title }} diff --git a/.github/web/static-s3/github/web-s3-testing-deploy-cicd.yml b/.github/web/static-s3/github/web-s3-testing-deploy-cicd.yml index 012e51c..63d9268 100644 --- a/.github/web/static-s3/github/web-s3-testing-deploy-cicd.yml +++ b/.github/web/static-s3/github/web-s3-testing-deploy-cicd.yml @@ -35,7 +35,7 @@ jobs: generate-pr: needs: build_deploy - uses: ./.github/workflows/web-s3-generate-pr.yml + uses: steplix/cicd-steplix/.github/workflows/web-s3-generate-pr.yml@main with: destination-branch-name: ${{ vars.DESTINATION_PR_ON_TESTING_WORKFLOW }} pr-title: " is TAG VERSION INCREMENT: PUSHING testing INTO ${{ vars.DESTINATION_PR_ON_TESTING_WORKFLOW }}" From 22765d4f5857097ab8c98b788d0194e232f8e5b1 Mon Sep 17 00:00:00 2001 From: leandro Date: Wed, 15 Feb 2023 17:55:42 -0300 Subject: [PATCH 03/44] refactor pipes --- .github/workflows/web-s3-create-tag.yml | 42 ------------------- .github/workflows/web-s3-develop-push.yml | 0 .github/workflows/web-s3-generate-pr.yml | 38 ----------------- .github/workflows/web-s3-hotfix-push.yml | 0 .github/workflows/web-s3-master-push.yml | 0 .github/workflows/web-s3-release-deploy.yml | 0 .github/workflows/web-s3-testing-deploy.yml | 0 .github/workflows/web-s3-validate.yml | 26 ------------ .../github/web-s3-develop-push-cicd.yml | 0 .../github/web-s3-hotfix-push-cicd.yml | 0 .../github/web-s3-master-push-cicd.yml | 0 ...web-s3-realease-production-deploy-cicd.yml | 0 .../github/web-s3-testing-deploy-cicd.yml | 0 13 files changed, 106 deletions(-) delete mode 100644 .github/workflows/web-s3-create-tag.yml create mode 100644 .github/workflows/web-s3-develop-push.yml delete mode 100644 .github/workflows/web-s3-generate-pr.yml create mode 100644 .github/workflows/web-s3-hotfix-push.yml create mode 100644 .github/workflows/web-s3-master-push.yml create mode 100644 .github/workflows/web-s3-release-deploy.yml create mode 100644 .github/workflows/web-s3-testing-deploy.yml delete mode 100644 .github/workflows/web-s3-validate.yml rename {.github/web => web}/static-s3/github/web-s3-develop-push-cicd.yml (100%) rename {.github/web => web}/static-s3/github/web-s3-hotfix-push-cicd.yml (100%) rename {.github/web => web}/static-s3/github/web-s3-master-push-cicd.yml (100%) rename {.github/web => web}/static-s3/github/web-s3-realease-production-deploy-cicd.yml (100%) rename {.github/web => web}/static-s3/github/web-s3-testing-deploy-cicd.yml (100%) diff --git a/.github/workflows/web-s3-create-tag.yml b/.github/workflows/web-s3-create-tag.yml deleted file mode 100644 index 71abdd4..0000000 --- a/.github/workflows/web-s3-create-tag.yml +++ /dev/null @@ -1,42 +0,0 @@ -name: Create TAG - -on: - workflow_call: - inputs: - text-where-search-for-parameters: - type: string - description: 'Message to parse. Defaults to head commit message' - required: false - default: ${{ github.event.head_commit.message }} - outputs: - tag: - description: "The tag created" - value: ${{ jobs.tagging.outputs.tag }} - -jobs: - - ### Running the TAG creation - - tagging: - runs-on: ubuntu-latest - outputs: - tag: ${{ steps.bumped_tag.outputs.version }} - steps: - - uses: steplix/cicd-check-parameter@1.0.0 - id: args - with: - message: ${{ inputs.text-where-search-for-parameters}} - param-0: major - param-1: minor - - - name: Get bumping mode - id: bump-mode - run: echo "mode=${{ (steps.args.outputs.param-0 == 'true' && 'major') || (steps.args.outputs.param-1 == 'true' && 'minor') || 'patch' }}" >> $GITHUB_OUTPUT - - # Bump tag without affecting repository - - uses: zwaldowski/semver-release-action@v3 - name: Get bumped tag - id: bumped_tag - with: - bump: ${{ steps.bump-mode.outputs.mode }} - github_token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/web-s3-develop-push.yml b/.github/workflows/web-s3-develop-push.yml new file mode 100644 index 0000000..e69de29 diff --git a/.github/workflows/web-s3-generate-pr.yml b/.github/workflows/web-s3-generate-pr.yml deleted file mode 100644 index c47f671..0000000 --- a/.github/workflows/web-s3-generate-pr.yml +++ /dev/null @@ -1,38 +0,0 @@ -name: generate pr - -on: - workflow_call: - inputs: - origin-branch-name: - type: string - description: "Name of the branch of origin from which the pr starts. If blank, default: triggered branch" - default: "" - required: false - destination-branch-name: - type: string - description: "Destination branch name for the pr" - required: true - pr-title: - type: string - description: "Title for the pr" - default: "An automated PR" - required: false - - - -jobs: - - ### Generating PR - - generate-pr: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: generate-pr - id: open-pr - uses: repo-sync/pull-request@v2 - with: - source_branch: ${{ inputs.origin-branch-name }} - destination_branch: ${{ inputs.destination-branch-name }} - pr_title: ${{ inputs.pr-title }} - - run: echo "PR GENERATED SUCCESSFULLY" \ No newline at end of file diff --git a/.github/workflows/web-s3-hotfix-push.yml b/.github/workflows/web-s3-hotfix-push.yml new file mode 100644 index 0000000..e69de29 diff --git a/.github/workflows/web-s3-master-push.yml b/.github/workflows/web-s3-master-push.yml new file mode 100644 index 0000000..e69de29 diff --git a/.github/workflows/web-s3-release-deploy.yml b/.github/workflows/web-s3-release-deploy.yml new file mode 100644 index 0000000..e69de29 diff --git a/.github/workflows/web-s3-testing-deploy.yml b/.github/workflows/web-s3-testing-deploy.yml new file mode 100644 index 0000000..e69de29 diff --git a/.github/workflows/web-s3-validate.yml b/.github/workflows/web-s3-validate.yml deleted file mode 100644 index ea53a4a..0000000 --- a/.github/workflows/web-s3-validate.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: Test - -on: - workflow_call: - inputs: - node-version: - description: 'Node version to use' - type: string - default: 14.18.0 - required: false - -jobs: - - ### Running the Test - - verify: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - node-version: ${{ inputs.node-version }} - - run: npm ci - - run: npm run lint --if-present - - run: npm run test --if-present - - run: echo "TEST SUCCESSFULLY" diff --git a/.github/web/static-s3/github/web-s3-develop-push-cicd.yml b/web/static-s3/github/web-s3-develop-push-cicd.yml similarity index 100% rename from .github/web/static-s3/github/web-s3-develop-push-cicd.yml rename to web/static-s3/github/web-s3-develop-push-cicd.yml diff --git a/.github/web/static-s3/github/web-s3-hotfix-push-cicd.yml b/web/static-s3/github/web-s3-hotfix-push-cicd.yml similarity index 100% rename from .github/web/static-s3/github/web-s3-hotfix-push-cicd.yml rename to web/static-s3/github/web-s3-hotfix-push-cicd.yml diff --git a/.github/web/static-s3/github/web-s3-master-push-cicd.yml b/web/static-s3/github/web-s3-master-push-cicd.yml similarity index 100% rename from .github/web/static-s3/github/web-s3-master-push-cicd.yml rename to web/static-s3/github/web-s3-master-push-cicd.yml diff --git a/.github/web/static-s3/github/web-s3-realease-production-deploy-cicd.yml b/web/static-s3/github/web-s3-realease-production-deploy-cicd.yml similarity index 100% rename from .github/web/static-s3/github/web-s3-realease-production-deploy-cicd.yml rename to web/static-s3/github/web-s3-realease-production-deploy-cicd.yml diff --git a/.github/web/static-s3/github/web-s3-testing-deploy-cicd.yml b/web/static-s3/github/web-s3-testing-deploy-cicd.yml similarity index 100% rename from .github/web/static-s3/github/web-s3-testing-deploy-cicd.yml rename to web/static-s3/github/web-s3-testing-deploy-cicd.yml From e4b5cd72709945142a950678e2b809cd54cc203e Mon Sep 17 00:00:00 2001 From: leandro Date: Wed, 15 Feb 2023 17:56:14 -0300 Subject: [PATCH 04/44] refactor finish --- .github/workflows/web-s3-develop-push.yml | 81 +++++++++++++++ .github/workflows/web-s3-hotfix-push.yml | 85 ++++++++++++++++ .github/workflows/web-s3-master-push.yml | 99 +++++++++++++++++++ .github/workflows/web-s3-release-deploy.yml | 83 ++++++++++++++++ .github/workflows/web-s3-testing-deploy.yml | 93 +++++++++++++++++ .../github/web-s3-develop-push-cicd.yml | 46 +++------ .../github/web-s3-hotfix-push-cicd.yml | 53 +++------- .../github/web-s3-master-push-cicd.yml | 57 +++-------- ...web-s3-realease-production-deploy-cicd.yml | 67 ++++--------- .../github/web-s3-testing-deploy-cicd.yml | 59 ++++------- 10 files changed, 518 insertions(+), 205 deletions(-) diff --git a/.github/workflows/web-s3-develop-push.yml b/.github/workflows/web-s3-develop-push.yml index e69de29..37557e3 100644 --- a/.github/workflows/web-s3-develop-push.yml +++ b/.github/workflows/web-s3-develop-push.yml @@ -0,0 +1,81 @@ +name: Push in development branch +run-name: > + "Create PR FROM develop TO ${{ inputs.DESTINATION_PR_ON_DEVELOP_WORKFLOW }}: ${{ github.event.head_commit.message }}" + +on: + workflow_call: + inputs: + NODE_VERSION: + description: 'Node version to use' + type: string + default: 14.18.0 + required: false + DESTINATION_PR: + description: 'Branch to target MR' + type: string + default: testing + required: false + PR_TITLE: + type: string + description: "Title for the pr" + default: "Pushing develop" + required: false + SLACK_CHANNEL: + type: string + description: Slack channel to send notifications + required: false + secrets: + SLACK_WEBHOOK_URL: + required: true + +jobs: + + testing: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: ${{ inputs.NODE_VERSION }} + - run: npm ci + - run: npm run lint --if-present + - run: npm run test --if-present + - run: echo "TEST SUCCESSFULLY" + + build: + needs: [ testing ] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: ${{ inputs.NODE_VERSION }} + - run: npm ci + - run: npm run release + + + generate-pr: + needs: [ build ] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: generate-pr + id: open-pr + uses: repo-sync/pull-request@v2 + with: + destination_branch: ${{ inputs.DESTINATION_PR }} + pr_title: ${{ inputs.PR_TITLE }} + - run: echo "PR GENERATED SUCCESSFULLY" + + notify: + if: ${{ always() }} + needs: [testing, build, generate-pr] + runs-on: ubuntu-latest + steps: + - name: Notify Slack + uses: steplix/cicd-notify@1.0.0 + with: + template: 'push' + status: ${{ needs.testing.result || needs.build.result || needs.generate-pr.result }} + slack_webhook_url: ${{ secrets.SLACK_WEBHOOK_URL }} + channel: ${{ inputs.SLACK_CHANNEL }} \ No newline at end of file diff --git a/.github/workflows/web-s3-hotfix-push.yml b/.github/workflows/web-s3-hotfix-push.yml index e69de29..bb472c4 100644 --- a/.github/workflows/web-s3-hotfix-push.yml +++ b/.github/workflows/web-s3-hotfix-push.yml @@ -0,0 +1,85 @@ +name: Push Hotfix in master branch +run-name: > + Push: ${{ github.ref_name }} + +on: + workflow_call: + inputs: + NODE_VERSION: + description: 'Node version to use' + type: string + default: 14.18.0 + required: false + DESTINATION_PR_MASTER: + description: 'Branch to target MR' + type: string + default: master + required: false + DESTINATION_PR_DEVELOP: + description: 'Branch to target MR' + type: string + default: develop + required: false + SLACK_CHANNEL: + type: string + description: Slack channel to send notifications + required: false + secrets: + SLACK_WEBHOOK_URL: + required: true + +jobs: + + testing: + uses: steplix/cicd-steplix/.github/workflows/web-s3-validate.yml@main + with: + node-version: ${{ inputs.NODE_VERSION }} + + build: + needs: [ testing ] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: ${{ inputs.NODE_VERSION }} + - run: npm ci + - run: npm run release + + generate-pr-to-master: + needs: [testing,build] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: generate-pr + id: open-pr + uses: repo-sync/pull-request@v2 + with: + destination_branch: ${{ inputs.DESTINATION_PR_MASTER }} + pr_title: " is TAG VERSION INCREMENT: Pushing HOTFIX ${{ github.ref_name }} into ${{ inputs.DESTINATION_PR_MASTER }}" + - run: echo "PR GENERATED SUCCESSFULLY" + + generate-pr-to-develop: + needs: [testing,build] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: generate-pr + id: open-pr + uses: repo-sync/pull-request@v2 + with: + destination_branch: ${{ inputs.DESTINATION_PR_DEVELOP }} + pr-title: "Pushing HOTFIX ${{ github.ref_name }} into ${{ inputs.DESTINATION_PR_DEVELOP }}" + + notify: + if: ${{ always() }} + needs: [ testing,build,generate-pr-to-master,generate-pr-to-develop ] + runs-on: ubuntu-latest + steps: + - name: Notify Slack + uses: steplix/cicd-notify@1.0.0 + with: + template: 'push' + status: ${{ needs.testing.result || needs.build.result || needs.generate-pr-to-master.result || needs.generate-pr-to-develop.result }} + slack_webhook_url: ${{ secrets.SLACK_WEBHOOK }} + channel: ${{ inputs.SLACK_CHANNEL }} \ No newline at end of file diff --git a/.github/workflows/web-s3-master-push.yml b/.github/workflows/web-s3-master-push.yml index e69de29..f4ec00d 100644 --- a/.github/workflows/web-s3-master-push.yml +++ b/.github/workflows/web-s3-master-push.yml @@ -0,0 +1,99 @@ +name: Push in master branch +run-name: > + ${{ github.event.pull_request.title }} + +on: + workflow_call: + inputs: + NODE_VERSION: + description: 'Node version to use' + type: string + default: 14.18.0 + required: false + SLACK_CHANNEL: + type: string + description: Slack channel to send notifications + required: false + AWS_BUCKET: + type: string + description: Bucket S3 to copy files for deploy + required: true + TEXT-WHERE-SEARCH-FOR-PARAMETERS: + type: string + description: 'Message to parse. Defaults to head commit message' + required: false + default: ${{ github.event.head_commit.message }} + secrets: + SLACK_WEBHOOK_URL: + required: true + AWS_KEY_ID: + required: true + AWS_SECRET_ACCESS_KEY: + required: true + AWS_REGION: + required: true + + +jobs: + + tagging: + runs-on: ubuntu-latest + outputs: + tag: ${{ steps.bumped_tag.outputs.version }} + steps: + - uses: steplix/cicd-check-parameter@1.0.0 + id: args + with: + message: ${{ inputs.TEXT-WHERE-SEARCH-FOR-PARAMETERS}} + param-0: major + param-1: minor + + - name: Get bumping mode + id: bump-mode + run: echo "mode=${{ (steps.args.outputs.param-0 == 'true' && 'major') || (steps.args.outputs.param-1 == 'true' && 'minor') || 'patch' }}" >> $GITHUB_OUTPUT + + # Bump tag without affecting repository + - uses: zwaldowski/semver-release-action@v3 + name: Get bumped tag + id: bumped_tag + with: + bump: ${{ steps.bump-mode.outputs.mode }} + github_token: ${{ secrets.GITHUB_TOKEN }} + + build-zip-upload: + needs: [ tagging ] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: ${{ inputs.NODE_VERSION }} + - run: npm ci + - run: npm run release + #ZIP + - name: generate-zip + id: zip + run: cd out && tar -czvf ${{ needs.tagging.outputs.tag }}.tar.gz * + + #UPLOAD + - uses: aws-actions/configure-aws-credentials@v1.7.0 + with: + aws-access-key-id: ${{ secrets.AWS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ secrets.AWS_REGION }} + - name: copy files to S3 + run: | + aws s3 cp out/${{ needs.tagging.outputs.tag }}.tar.gz s3://${{ inputs.AWS_BUCKET }}/${{ needs.tagging.outputs.tag }}.tar.gz + + + notify: + if: ${{ always() }} + needs: [ tagging,build-zip-upload ] + runs-on: ubuntu-latest + steps: + - name: Notify Slack + uses: steplix/cicd-notify@0.0.17 + with: + template: 'push' + status: ${{ needs.tagging.result || needs.build-zip-upload.result }} + slack_webhook_url: ${{ secrets.SLACK_WEBHOOK }} \ No newline at end of file diff --git a/.github/workflows/web-s3-release-deploy.yml b/.github/workflows/web-s3-release-deploy.yml index e69de29..f305220 100644 --- a/.github/workflows/web-s3-release-deploy.yml +++ b/.github/workflows/web-s3-release-deploy.yml @@ -0,0 +1,83 @@ +name: Deployment to production +run-name: > + Production deployment ${{ github.event.release.tag_name }}: ${{ github.event.release.name }} + +on: + workflow_call: + inputs: + SLACK_CHANNEL: + type: string + description: Slack channel to send notifications + required: false + AWS_BUCKET: + type: string + description: Bucket S3 to copy files for deploy + required: true + AWS_BUCKET_ARTIFACT: + type: string + description: Bucket S3 to download artifact to deploy + required: true + secrets: + SLACK_WEBHOOK_URL: + required: true + AWS_KEY_ID: + required: true + AWS_SECRET_ACCESS_KEY: + required: true + AWS_REGION: + required: true + AWS_CLOUDFRONT_DISTRIBUTION_ID: + required: true + +jobs: + + ## DEPLOY + + download_unzip_deploy: + runs-on: ubuntu-latest + steps: + #DOWNLOAD + - uses: aws-actions/configure-aws-credentials@v1.7.0 + with: + aws-access-key-id: ${{ secrets.AWS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ secrets.AWS_REGION }} + + - name: download zip from S3 + run: | + aws s3 cp s3://${{ inputs.AWS_BUCKET_ARTIFACT }}/${{ github.event.release.tag_name }}.tar.gz . + #UNZIP + - name: mkdir + run: mkdir output + + - name: un-zip + id: unzip + run: tar -xvzf ${{ github.event.release.tag_name }}.tar.gz -C output + + #UPLOAD + - uses: aws-actions/configure-aws-credentials@v1.7.0 + with: + aws-access-key-id: ${{ secrets.PROD_AWS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ secrets.PROD_AWS_REGION }} + - name: copy files to S3 + run: | + aws s3 sync output s3://${{ inputs.AWS_BUCKET }} + - name: Cloudfront invalidation + run: | + aws cloudfront create-invalidation --distribution-id ${{ inputs.AWS_CLOUDFRONT_DISTRIBUTION_ID }} --paths "/*" + + + + notify: + if: ${{ always() }} + needs: [ download_unzip_deploy ] + runs-on: ubuntu-latest + steps: + - name: Notify Slack + uses: steplix/cicd-notify@1.0.0 + with: + template: 'push' + status: ${{ needs.download_unzip_deploy.result}} + slack_webhook_url: ${{ secrets.SLACK_WEBHOOK }} + channel: ${{ inputs.SLACK_CHANNEL }} \ No newline at end of file diff --git a/.github/workflows/web-s3-testing-deploy.yml b/.github/workflows/web-s3-testing-deploy.yml index e69de29..fd267a5 100644 --- a/.github/workflows/web-s3-testing-deploy.yml +++ b/.github/workflows/web-s3-testing-deploy.yml @@ -0,0 +1,93 @@ +name: Push in testing branch +run-name: > + "Deploying testing and creating PR to ${{ vars.DESTINATION_PR_ON_TESTING_WORKFLOW }}" + +on: + workflow_call: + inputs: + NODE_VERSION: + description: 'Node version to use' + type: string + default: 14.18.0 + required: false + DESTINATION_PR: + description: 'Branch to target MR' + type: string + default: master + required: false + PR_TITLE: + type: string + description: "Title for the pr" + default: "Pushing testing" + required: false + SLACK_CHANNEL: + type: string + description: Slack channel to send notifications + required: false + AWS_BUCKET: + type: string + description: Bucket S3 to copy files for deploy + required: true + secrets: + SLACK_WEBHOOK_URL: + required: true + AWS_KEY_ID: + required: true + AWS_SECRET_ACCESS_KEY: + required: true + AWS_REGION: + required: true + AWS_CLOUDFRONT_DISTRIBUTION_ID: + required: true + +jobs: + + build_deploy: + runs-on: ubuntu-latest + steps: + #BUILD + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: ${{ inputs.NODE_VERSION }} + - run: npm ci + - run: npm run release + #UPLOAD + - uses: aws-actions/configure-aws-credentials@v1.7.0 + with: + aws-access-key-id: ${{ secrets.AWS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ secrets.AWS_REGION }} + - name: copy files to S3 + run: | + aws s3 sync out s3://${{ inputs.AWS_BUCKET }} + - name: Cloudfront invalidation + run: | + aws cloudfront create-invalidation --distribution-id ${{ inputs.AWS_CLOUDFRONT_DISTRIBUTION_ID }} --paths "/*" + + + generate-pr: + needs: [ build_deploy ] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: generate-pr + id: open-pr + uses: repo-sync/pull-request@v2 + with: + destination_branch: ${{ inputs.DESTINATION_PR }} + pr_title: ${{ inputs.PR_TITLE }} + - run: echo "PR GENERATED SUCCESSFULLY" + + notify: + if: ${{ always() }} + needs: [ build_deploy,generate-pr ] + runs-on: ubuntu-latest + steps: + - name: Notify Slack + uses: steplix/cicd-notify@1.0.0 + with: + template: 'push' + status: ${{ needs.build_deploy.result || needs.generate-pr.result }} + slack_webhook_url: ${{ secrets.SLACK_WEBHOOK }} + channel: ${{ inputs.SLACK_CHANNEL }} \ No newline at end of file diff --git a/web/static-s3/github/web-s3-develop-push-cicd.yml b/web/static-s3/github/web-s3-develop-push-cicd.yml index 7e6aa74..b92cfad 100644 --- a/web/static-s3/github/web-s3-develop-push-cicd.yml +++ b/web/static-s3/github/web-s3-develop-push-cicd.yml @@ -7,40 +7,20 @@ on: branches: - develop +env: + NODE_VERSION: ${{ vars.NODE_VERSION }} + DESTINATION_PR: ${{ vars.DESTINATION_PR_ON_DEVELOP_WORKFLOW }} + PR_TITLE: "Pushing develop into ${{ vars.DESTINATION_PR_ON_DEVELOP_WORKFLOW }}" + SLACK_CHANNEL: ${{ vars.SLACK_CHANNEL }} jobs: - testing: - uses: steplix/cicd-steplix/.github/workflows/web-s3-validate.yml@main - with: - node-version: ${{ vars.NODE_VERSION }} - - build: - needs: [ testing ] - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - node-version: ${{ vars.NODE_VERSION }} - - run: npm ci - - run: npm run release - - generate-pr: - needs: [build] - uses: steplix/cicd-steplix/.github/workflows/web-s3-generate-pr.yml@main + develop: + uses: steplix/cicd-steplix/.github/workflows/web-s3-develop-push.yml@feature/addStaticWebWorkflows with: - destination-branch-name: ${{ vars.DESTINATION_PR_ON_DEVELOP_WORKFLOW }} - pr-title: "Pushing develop into ${{ vars.DESTINATION_PR_ON_DEVELOP_WORKFLOW }}" - - notify: - if: ${{ always() }} - needs: [testing, build, generate-pr] - runs-on: ubuntu-latest - steps: - - name: Notify Slack - uses: steplix/cicd-notify@0.0.17 - with: - template: 'push' - status: ${{ needs.testing.result || needs.build.result || needs.generate-pr.result }} - slack_webhook_url: ${{ secrets.SLACK_WEBHOOK }} \ No newline at end of file + NODE_VERSION: ${{ env.NODE_VERSION }} + DESTINATION_PR: ${{ env.DESTINATION_PR }} + PR_TITLE: ${{ env.PR_TITLE }} + SLACK_CHANNEL: ${{ env.SLACK_CHANNEL }} + secrets: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} diff --git a/web/static-s3/github/web-s3-hotfix-push-cicd.yml b/web/static-s3/github/web-s3-hotfix-push-cicd.yml index 2a8d117..dadbcde 100644 --- a/web/static-s3/github/web-s3-hotfix-push-cicd.yml +++ b/web/static-s3/github/web-s3-hotfix-push-cicd.yml @@ -7,47 +7,20 @@ on: branches: - 'hotfix/**' +env: + NODE_VERSION: ${{ vars.NODE_VERSION }} + DESTINATION_PR_MASTER: ${{ vars.DESTINATION_PR_ON_TESTING_WORKFLOW }} + DESTINATION_PR_DEVELOP: develop + SLACK_CHANNEL: ${{ vars.SLACK_CHANNEL }} jobs: - testing: - uses: steplix/cicd-steplix/.github/workflows/web-s3-validate.yml@main + hotfix: + uses: steplix/cicd-steplix/.github/workflows/web-s3-develop-push.yml@feature/addStaticWebWorkflows with: - node-version: ${{ vars.NODE_VERSION }} - - build: - needs: [ testing ] - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - node-version: ${{ vars.NODE_VERSION }} - - run: npm ci - - run: npm run release - - generate-pr-to-master: - needs: [testing,build] - uses: steplix/cicd-steplix/.github/workflows/web-s3-generate-pr.yml@main - with: - destination-branch-name: ${{ vars.DESTINATION_PR_ON_TESTING_WORKFLOW }} - pr-title: " is TAG VERSION INCREMENT: Pushing HOTFIX ${{ github.ref_name }} into Master" - - generate-pr-to-develop: - needs: [testing,build] - uses: steplix/cicd-steplix/.github/workflows/web-s3-generate-pr.yml@main - with: - destination-branch-name: ${{ vars.DESTINATION_PR_ON_DEVELOP_WORKFLOW }} - pr-title: "Pushing HOTFIX ${{ github.ref_name }} into Develop" - - notify: - if: ${{ always() }} - needs: [ testing,build,generate-pr-to-master,generate-pr-to-develop ] - runs-on: ubuntu-latest - steps: - - name: Notify Slack - uses: steplix/cicd-notify@0.0.17 - with: - template: 'push' - status: ${{ needs.testing.result || needs.build.result || needs.generate-pr-to-master.result || needs.generate-pr-to-develop.result }} - slack_webhook_url: ${{ secrets.SLACK_WEBHOOK }} \ No newline at end of file + NODE_VERSION: ${{ env.NODE_VERSION }} + DESTINATION_PR_MASTER: ${{ env.DESTINATION_PR_MASTER }} + DESTINATION_PR_DEVELOP: ${{ env.DESTINATION_PR_DEVELOP }} + SLACK_CHANNEL: ${{ env.SLACK_CHANNEL }} + secrets: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} diff --git a/web/static-s3/github/web-s3-master-push-cicd.yml b/web/static-s3/github/web-s3-master-push-cicd.yml index d25acbc..e593e7a 100644 --- a/web/static-s3/github/web-s3-master-push-cicd.yml +++ b/web/static-s3/github/web-s3-master-push-cicd.yml @@ -8,48 +8,21 @@ on: - master +env: + NODE_VERSION: ${{ vars.NODE_VERSION }} + SLACK_CHANNEL: ${{ vars.SLACK_CHANNEL }} + AWS_BUCKET: ${{ vars.PROD_AWS_BUCKET_ARTIFACT }} + jobs: - tagging: - if: github.event.pull_request.merged == true - uses: steplix/cicd-steplix/.github/workflows/web-s3-create-tag.yml@main + master: + uses: steplix/cicd-steplix/.github/workflows/web-s3-master-push.yml@feature/addStaticWebWorkflows with: - text-where-search-for-parameters: ${{ github.event.pull_request.title }} - - build-zip-upload: - needs: [ tagging ] - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - node-version: ${{ vars.NODE_VERSION }} - - run: npm ci - - run: npm run release - #ZIP - - name: generate-zip - id: zip - run: cd out && tar -czvf ${{ needs.tagging.outputs.tag }}.tar.gz * - - #UPLOAD - - uses: aws-actions/configure-aws-credentials@v1.7.0 - with: - aws-access-key-id: ${{ secrets.PROD_AWS_KEY_ID }} - aws-secret-access-key: ${{ secrets.PROD_AWS_SECRET_ACCESS_KEY }} - aws-region: ${{ secrets.PROD_AWS_REGION }} - - name: copy files to S3 - run: | - aws s3 cp out/${{ needs.tagging.outputs.tag }}.tar.gz s3://${{ vars.PROD_AWS_BUCKET_ARTIFACT }}/${{ needs.tagging.outputs.tag }}.tar.gz - - - notify: - if: ${{ always() }} - needs: [ tagging,build-zip-upload ] - runs-on: ubuntu-latest - steps: - - name: Notify Slack - uses: steplix/cicd-notify@0.0.17 - with: - template: 'push' - status: ${{ needs.tagging.result || needs.build-zip-upload.result }} - slack_webhook_url: ${{ secrets.SLACK_WEBHOOK }} \ No newline at end of file + NODE_VERSION: ${{ env.NODE_VERSION }} + SLACK_CHANNEL: ${{ env.SLACK_CHANNEL }} + AWS_BUCKET: ${{ env.AWS_BUCKET }} + secrets: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} + AWS_KEY_ID: ${{ secrets.TEST_AWS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.TEST_AWS_SECRET_ACCESS_KEY }} + AWS_REGION: ${{ secrets.TEST_AWS_REGION }} diff --git a/web/static-s3/github/web-s3-realease-production-deploy-cicd.yml b/web/static-s3/github/web-s3-realease-production-deploy-cicd.yml index 60f0e8b..56d6bd4 100644 --- a/web/static-s3/github/web-s3-realease-production-deploy-cicd.yml +++ b/web/static-s3/github/web-s3-realease-production-deploy-cicd.yml @@ -6,54 +6,23 @@ on: types: [published] -jobs: - - ## DEPLOY - - download_unzip_deploy: - runs-on: ubuntu-latest - steps: - #DOWNLOAD - - uses: aws-actions/configure-aws-credentials@v1.7.0 - with: - aws-access-key-id: ${{ secrets.PROD_AWS_KEY_ID }} - aws-secret-access-key: ${{ secrets.PROD_AWS_SECRET_ACCESS_KEY }} - aws-region: ${{ secrets.PROD_AWS_REGION }} - - - name: download zip from S3 - run: | - aws s3 cp s3://${{ vars.PROD_AWS_BUCKET_ARTIFACT }}/${{ github.event.release.tag_name }}.tar.gz . - #UNZIP - - name: mkdir - run: mkdir output - - - name: un-zip - id: unzip - run: tar -xvzf ${{ github.event.release.tag_name }}.tar.gz -C output - - #UPLOAD - - uses: aws-actions/configure-aws-credentials@v1.7.0 - with: - aws-access-key-id: ${{ secrets.PROD_AWS_KEY_ID }} - aws-secret-access-key: ${{ secrets.PROD_AWS_SECRET_ACCESS_KEY }} - aws-region: ${{ secrets.PROD_AWS_REGION }} - - name: copy files to S3 - run: | - aws s3 sync output s3://${{ vars.PROD_AWS_BUCKET }} - - name: Cloudfront invalidation - run: | - aws cloudfront create-invalidation --distribution-id ${{ vars.PROD_AWS_CLOUDFRONT_DISTRIBUTION_ID }} --paths "/*" - +env: + SLACK_CHANNEL: ${{ vars.SLACK_CHANNEL }} + AWS_BUCKET: ${{ vars.PROD_AWS_BUCKET }} + AWS_BUCKET_ARTIFACT: ${{ vars.PROD_AWS_BUCKET_ARTIFACT }} +jobs: - notify: - if: ${{ always() }} - needs: [ download_unzip_deploy ] - runs-on: ubuntu-latest - steps: - - name: Notify Slack - uses: steplix/cicd-notify@0.0.17 - with: - template: 'push' - status: ${{ needs.download_unzip_deploy.result}} - slack_webhook_url: ${{ secrets.SLACK_WEBHOOK }} \ No newline at end of file + production: + uses: steplix/cicd-steplix/.github/workflows/web-s3-release-deploy.yml@feature/addStaticWebWorkflows + with: + NODE_VERSION: ${{ env.NODE_VERSION }} + AWS_BUCKET: ${{ env.AWS_BUCKET }} + AWS_BUCKET_ARTIFACT: ${{ env.AWS_BUCKET_ARTIFACT }} + SLACK_CHANNEL: ${{ env.SLACK_CHANNEL }} + secrets: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} + AWS_KEY_ID: ${{ secrets.PROD_AWS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.PROD_AWS_SECRET_ACCESS_KEY }} + AWS_REGION: ${{ secrets.PROD_AWS_REGION }} + AWS_CLOUDFRONT_DISTRIBUTION_ID: ${{ vars.PROD_AWS_CLOUDFRONT_DISTRIBUTION_ID }} diff --git a/web/static-s3/github/web-s3-testing-deploy-cicd.yml b/web/static-s3/github/web-s3-testing-deploy-cicd.yml index 63d9268..cfc81bc 100644 --- a/web/static-s3/github/web-s3-testing-deploy-cicd.yml +++ b/web/static-s3/github/web-s3-testing-deploy-cicd.yml @@ -6,48 +6,25 @@ on: branches: - testing +env: + NODE_VERSION: ${{ vars.NODE_VERSION }} + DESTINATION_PR: ${{ vars.DESTINATION_PR_ON_TESTING_WORKFLOW }} + PR_TITLE: " is TAG VERSION INCREMENT: PUSHING testing INTO ${{ vars.DESTINATION_PR_ON_TESTING_WORKFLOW }}" + SLACK_CHANNEL: ${{ vars.SLACK_CHANNEL }} + AWS_BUCKET: ${{ vars.TEST_AWS_BUCKET }} jobs: - build_deploy: - runs-on: ubuntu-latest - steps: - #BUILD - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - node-version: ${{ vars.NODE_VERSION }} - - run: npm ci - - run: npm run release - #UPLOAD - - uses: aws-actions/configure-aws-credentials@v1.7.0 - with: - aws-access-key-id: ${{ secrets.TEST_AWS_KEY_ID }} - aws-secret-access-key: ${{ secrets.TEST_AWS_SECRET_ACCESS_KEY }} - aws-region: ${{ secrets.TEST_AWS_REGION }} - - name: copy files to S3 - run: | - aws s3 sync out s3://${{ vars.TEST_AWS_BUCKET }} - - name: Cloudfront invalidation - run: | - aws cloudfront create-invalidation --distribution-id ${{ vars.TEST_AWS_CLOUDFRONT_DISTRIBUTION_ID }} --paths "/*" - - - generate-pr: - needs: build_deploy - uses: steplix/cicd-steplix/.github/workflows/web-s3-generate-pr.yml@main + testing: + uses: steplix/cicd-steplix/.github/workflows/web-s3-testing-deploy.yml@feature/addStaticWebWorkflows with: - destination-branch-name: ${{ vars.DESTINATION_PR_ON_TESTING_WORKFLOW }} - pr-title: " is TAG VERSION INCREMENT: PUSHING testing INTO ${{ vars.DESTINATION_PR_ON_TESTING_WORKFLOW }}" - - notify: - if: ${{ always() }} - needs: [ build_deploy,generate-pr ] - runs-on: ubuntu-latest - steps: - - name: Notify Slack - uses: steplix/cicd-notify@0.0.17 - with: - template: 'push' - status: ${{ needs.build_deploy.result || needs.generate-pr.result }} - slack_webhook_url: ${{ secrets.SLACK_WEBHOOK }} \ No newline at end of file + NODE_VERSION: ${{ env.NODE_VERSION }} + DESTINATION_PR: ${{ env.DESTINATION_PR }} + PR_TITLE: ${{ env.PR_TITLE }} + SLACK_CHANNEL: ${{ env.SLACK_CHANNEL }} + secrets: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} + AWS_KEY_ID: ${{ secrets.TEST_AWS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.TEST_AWS_SECRET_ACCESS_KEY }} + AWS_REGION: ${{ secrets.TEST_AWS_REGION }} + AWS_CLOUDFRONT_DISTRIBUTION_ID: ${{ vars.TEST_AWS_CLOUDFRONT_DISTRIBUTION_ID }} From a554c9de28983b8f39ebb8724d9fb95e48c2cfa9 Mon Sep 17 00:00:00 2001 From: leandro Date: Tue, 18 Apr 2023 20:10:52 +0200 Subject: [PATCH 05/44] fix references problems --- .github/workflows/web-s3-release-deploy.yml | 2 +- .github/workflows/web-s3-testing-deploy.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/web-s3-release-deploy.yml b/.github/workflows/web-s3-release-deploy.yml index f305220..389f3ef 100644 --- a/.github/workflows/web-s3-release-deploy.yml +++ b/.github/workflows/web-s3-release-deploy.yml @@ -65,7 +65,7 @@ jobs: aws s3 sync output s3://${{ inputs.AWS_BUCKET }} - name: Cloudfront invalidation run: | - aws cloudfront create-invalidation --distribution-id ${{ inputs.AWS_CLOUDFRONT_DISTRIBUTION_ID }} --paths "/*" + aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_CLOUDFRONT_DISTRIBUTION_ID }} --paths "/*" diff --git a/.github/workflows/web-s3-testing-deploy.yml b/.github/workflows/web-s3-testing-deploy.yml index fd267a5..3fa4308 100644 --- a/.github/workflows/web-s3-testing-deploy.yml +++ b/.github/workflows/web-s3-testing-deploy.yml @@ -63,7 +63,7 @@ jobs: aws s3 sync out s3://${{ inputs.AWS_BUCKET }} - name: Cloudfront invalidation run: | - aws cloudfront create-invalidation --distribution-id ${{ inputs.AWS_CLOUDFRONT_DISTRIBUTION_ID }} --paths "/*" + aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_CLOUDFRONT_DISTRIBUTION_ID }} --paths "/*" generate-pr: From bd3b9c1e7bc4662f19181acc81c1a969e6d1a26d Mon Sep 17 00:00:00 2001 From: leandro Date: Fri, 21 Apr 2023 14:36:11 +0200 Subject: [PATCH 06/44] testing --- .github/workflows/web-s3-testing-deploy.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/web-s3-testing-deploy.yml b/.github/workflows/web-s3-testing-deploy.yml index 3fa4308..03a3f1d 100644 --- a/.github/workflows/web-s3-testing-deploy.yml +++ b/.github/workflows/web-s3-testing-deploy.yml @@ -46,6 +46,7 @@ jobs: runs-on: ubuntu-latest steps: #BUILD + - run: echo "aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_CLOUDFRONT_DISTRIBUTION_ID }} --paths /*" - uses: actions/checkout@v3 - uses: actions/setup-node@v3 with: From a878d9d20959ca54c9efb0a12ebc28da9753f76e Mon Sep 17 00:00:00 2001 From: leandro Date: Fri, 21 Apr 2023 14:40:55 +0200 Subject: [PATCH 07/44] debuggin --- .github/workflows/web-s3-testing-deploy.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/web-s3-testing-deploy.yml b/.github/workflows/web-s3-testing-deploy.yml index 03a3f1d..bd1e838 100644 --- a/.github/workflows/web-s3-testing-deploy.yml +++ b/.github/workflows/web-s3-testing-deploy.yml @@ -28,6 +28,10 @@ on: type: string description: Bucket S3 to copy files for deploy required: true + AWS_CLOUDFRONT: + type: string + description: Only for test + required: true secrets: SLACK_WEBHOOK_URL: required: true @@ -47,6 +51,7 @@ jobs: steps: #BUILD - run: echo "aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_CLOUDFRONT_DISTRIBUTION_ID }} --paths /*" + - run: echo "aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_CLOUDFRONT_DISTRIBUTION_ID }} --paths /*" - uses: actions/checkout@v3 - uses: actions/setup-node@v3 with: From 20f6e37ba7fda7a5d65c3eb9f6e488fa80613c83 Mon Sep 17 00:00:00 2001 From: leandro Date: Fri, 21 Apr 2023 14:46:22 +0200 Subject: [PATCH 08/44] prueba --- .github/workflows/web-s3-testing-deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/web-s3-testing-deploy.yml b/.github/workflows/web-s3-testing-deploy.yml index bd1e838..3cb1888 100644 --- a/.github/workflows/web-s3-testing-deploy.yml +++ b/.github/workflows/web-s3-testing-deploy.yml @@ -51,7 +51,7 @@ jobs: steps: #BUILD - run: echo "aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_CLOUDFRONT_DISTRIBUTION_ID }} --paths /*" - - run: echo "aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_CLOUDFRONT_DISTRIBUTION_ID }} --paths /*" + - run: echo "aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_CLOUDFRONT }} --paths /*" - uses: actions/checkout@v3 - uses: actions/setup-node@v3 with: From d844773398d1f5f48974c1f14da11e28e4597ac4 Mon Sep 17 00:00:00 2001 From: leandro Date: Fri, 21 Apr 2023 14:47:23 +0200 Subject: [PATCH 09/44] debug --- .github/workflows/web-s3-testing-deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/web-s3-testing-deploy.yml b/.github/workflows/web-s3-testing-deploy.yml index 3cb1888..8d6d655 100644 --- a/.github/workflows/web-s3-testing-deploy.yml +++ b/.github/workflows/web-s3-testing-deploy.yml @@ -69,7 +69,7 @@ jobs: aws s3 sync out s3://${{ inputs.AWS_BUCKET }} - name: Cloudfront invalidation run: | - aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_CLOUDFRONT_DISTRIBUTION_ID }} --paths "/*" + aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_CLOUDFRONT }} --paths "/*" generate-pr: From e6fb8d4abf16cc3ed9b9f79cdc39ec8498646fca Mon Sep 17 00:00:00 2001 From: leandro Date: Fri, 21 Apr 2023 15:01:08 +0200 Subject: [PATCH 10/44] Fix reference problem --- .github/workflows/web-s3-release-deploy.yml | 8 +++++--- .github/workflows/web-s3-testing-deploy.yml | 10 +++------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/.github/workflows/web-s3-release-deploy.yml b/.github/workflows/web-s3-release-deploy.yml index 389f3ef..9c83be7 100644 --- a/.github/workflows/web-s3-release-deploy.yml +++ b/.github/workflows/web-s3-release-deploy.yml @@ -17,6 +17,10 @@ on: type: string description: Bucket S3 to download artifact to deploy required: true + AWS_CLOUDFRONT_DISTRIBUTION_ID: + type: string + description: CloudFront Distribution ID + required: true secrets: SLACK_WEBHOOK_URL: required: true @@ -26,8 +30,6 @@ on: required: true AWS_REGION: required: true - AWS_CLOUDFRONT_DISTRIBUTION_ID: - required: true jobs: @@ -65,7 +67,7 @@ jobs: aws s3 sync output s3://${{ inputs.AWS_BUCKET }} - name: Cloudfront invalidation run: | - aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_CLOUDFRONT_DISTRIBUTION_ID }} --paths "/*" + aws cloudfront create-invalidation --distribution-id ${{ inputs.AWS_CLOUDFRONT_DISTRIBUTION_ID }} --paths "/*" diff --git a/.github/workflows/web-s3-testing-deploy.yml b/.github/workflows/web-s3-testing-deploy.yml index 8d6d655..81dda3a 100644 --- a/.github/workflows/web-s3-testing-deploy.yml +++ b/.github/workflows/web-s3-testing-deploy.yml @@ -28,9 +28,9 @@ on: type: string description: Bucket S3 to copy files for deploy required: true - AWS_CLOUDFRONT: + AWS_CLOUDFRONT_DISTRIBUTION_ID: type: string - description: Only for test + description: CloudFront Distribution ID required: true secrets: SLACK_WEBHOOK_URL: @@ -41,8 +41,6 @@ on: required: true AWS_REGION: required: true - AWS_CLOUDFRONT_DISTRIBUTION_ID: - required: true jobs: @@ -50,8 +48,6 @@ jobs: runs-on: ubuntu-latest steps: #BUILD - - run: echo "aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_CLOUDFRONT_DISTRIBUTION_ID }} --paths /*" - - run: echo "aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_CLOUDFRONT }} --paths /*" - uses: actions/checkout@v3 - uses: actions/setup-node@v3 with: @@ -69,7 +65,7 @@ jobs: aws s3 sync out s3://${{ inputs.AWS_BUCKET }} - name: Cloudfront invalidation run: | - aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_CLOUDFRONT }} --paths "/*" + aws cloudfront create-invalidation --distribution-id ${{ inputs.AWS_CLOUDFRONT_DISTRIBUTION_ID }} --paths "/*" generate-pr: From 1492f14aa9b29f190e1d7bc75c9233309127c33f Mon Sep 17 00:00:00 2001 From: leandro Date: Fri, 21 Apr 2023 15:31:36 +0200 Subject: [PATCH 11/44] fix bug --- .github/workflows/web-s3-hotfix-push.yml | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/.github/workflows/web-s3-hotfix-push.yml b/.github/workflows/web-s3-hotfix-push.yml index bb472c4..98ccd18 100644 --- a/.github/workflows/web-s3-hotfix-push.yml +++ b/.github/workflows/web-s3-hotfix-push.yml @@ -31,9 +31,16 @@ on: jobs: testing: - uses: steplix/cicd-steplix/.github/workflows/web-s3-validate.yml@main - with: - node-version: ${{ inputs.NODE_VERSION }} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: ${{ inputs.NODE_VERSION }} + - run: npm ci + - run: npm run lint --if-present + - run: npm run test --if-present + - run: echo "TEST SUCCESSFULLY" build: needs: [ testing ] From 679d740007388a4f682210f95579803161b136b4 Mon Sep 17 00:00:00 2001 From: leandro Date: Fri, 21 Apr 2023 15:44:10 +0200 Subject: [PATCH 12/44] fix bug --- .github/workflows/web-s3-release-deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/web-s3-release-deploy.yml b/.github/workflows/web-s3-release-deploy.yml index 9c83be7..a840c65 100644 --- a/.github/workflows/web-s3-release-deploy.yml +++ b/.github/workflows/web-s3-release-deploy.yml @@ -61,7 +61,7 @@ jobs: with: aws-access-key-id: ${{ secrets.PROD_AWS_KEY_ID }} aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - aws-region: ${{ secrets.PROD_AWS_REGION }} + aws-region: ${{ secrets.AWS_REGION }} - name: copy files to S3 run: | aws s3 sync output s3://${{ inputs.AWS_BUCKET }} From 739c174f14a9c5afd21ad36998fb9bc712ed11b6 Mon Sep 17 00:00:00 2001 From: leandro Date: Fri, 21 Apr 2023 15:46:16 +0200 Subject: [PATCH 13/44] push --- .../github/web-s3-develop-push-cicd.yml | 13 ++++--------- .../github/web-s3-hotfix-push-cicd.yml | 17 +++++------------ ...cicd.yml => web-s3-production-push-cicd.yml} | 11 +++-------- .../web-s3-realease-production-deploy-cicd.yml | 14 ++++---------- .../github/web-s3-testing-deploy-cicd.yml | 17 ++++++----------- 5 files changed, 22 insertions(+), 50 deletions(-) rename web/static-s3/github/{web-s3-master-push-cicd.yml => web-s3-production-push-cicd.yml} (64%) diff --git a/web/static-s3/github/web-s3-develop-push-cicd.yml b/web/static-s3/github/web-s3-develop-push-cicd.yml index b92cfad..60cf50b 100644 --- a/web/static-s3/github/web-s3-develop-push-cicd.yml +++ b/web/static-s3/github/web-s3-develop-push-cicd.yml @@ -7,20 +7,15 @@ on: branches: - develop -env: - NODE_VERSION: ${{ vars.NODE_VERSION }} - DESTINATION_PR: ${{ vars.DESTINATION_PR_ON_DEVELOP_WORKFLOW }} - PR_TITLE: "Pushing develop into ${{ vars.DESTINATION_PR_ON_DEVELOP_WORKFLOW }}" - SLACK_CHANNEL: ${{ vars.SLACK_CHANNEL }} jobs: develop: uses: steplix/cicd-steplix/.github/workflows/web-s3-develop-push.yml@feature/addStaticWebWorkflows with: - NODE_VERSION: ${{ env.NODE_VERSION }} - DESTINATION_PR: ${{ env.DESTINATION_PR }} - PR_TITLE: ${{ env.PR_TITLE }} - SLACK_CHANNEL: ${{ env.SLACK_CHANNEL }} + NODE_VERSION: ${{ vars.NODE_VERSION }} + DESTINATION_PR: ${{ vars.DESTINATION_PR_ON_DEVELOP_WORKFLOW }} + PR_TITLE: "Pushing develop into ${{ vars.DESTINATION_PR_ON_DEVELOP_WORKFLOW }}" + SLACK_CHANNEL: ${{ vars.SLACK_CHANNEL }} secrets: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} diff --git a/web/static-s3/github/web-s3-hotfix-push-cicd.yml b/web/static-s3/github/web-s3-hotfix-push-cicd.yml index dadbcde..cf18af4 100644 --- a/web/static-s3/github/web-s3-hotfix-push-cicd.yml +++ b/web/static-s3/github/web-s3-hotfix-push-cicd.yml @@ -7,20 +7,13 @@ on: branches: - 'hotfix/**' -env: - NODE_VERSION: ${{ vars.NODE_VERSION }} - DESTINATION_PR_MASTER: ${{ vars.DESTINATION_PR_ON_TESTING_WORKFLOW }} - DESTINATION_PR_DEVELOP: develop - SLACK_CHANNEL: ${{ vars.SLACK_CHANNEL }} - jobs: - hotfix: - uses: steplix/cicd-steplix/.github/workflows/web-s3-develop-push.yml@feature/addStaticWebWorkflows + uses: steplix/cicd-steplix/.github/workflows/web-s3-hotfix-push.yml@feature/addStaticWebWorkflows with: - NODE_VERSION: ${{ env.NODE_VERSION }} - DESTINATION_PR_MASTER: ${{ env.DESTINATION_PR_MASTER }} - DESTINATION_PR_DEVELOP: ${{ env.DESTINATION_PR_DEVELOP }} - SLACK_CHANNEL: ${{ env.SLACK_CHANNEL }} + NODE_VERSION: ${{ vars.NODE_VERSION }} + DESTINATION_PR_MASTER: ${{ vars.DESTINATION_PR_ON_TESTING_WORKFLOW }} + DESTINATION_PR_DEVELOP: develop + SLACK_CHANNEL: ${{ vars.SLACK_CHANNEL }} secrets: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} diff --git a/web/static-s3/github/web-s3-master-push-cicd.yml b/web/static-s3/github/web-s3-production-push-cicd.yml similarity index 64% rename from web/static-s3/github/web-s3-master-push-cicd.yml rename to web/static-s3/github/web-s3-production-push-cicd.yml index e593e7a..55aaf62 100644 --- a/web/static-s3/github/web-s3-master-push-cicd.yml +++ b/web/static-s3/github/web-s3-production-push-cicd.yml @@ -8,19 +8,14 @@ on: - master -env: - NODE_VERSION: ${{ vars.NODE_VERSION }} - SLACK_CHANNEL: ${{ vars.SLACK_CHANNEL }} - AWS_BUCKET: ${{ vars.PROD_AWS_BUCKET_ARTIFACT }} - jobs: master: uses: steplix/cicd-steplix/.github/workflows/web-s3-master-push.yml@feature/addStaticWebWorkflows with: - NODE_VERSION: ${{ env.NODE_VERSION }} - SLACK_CHANNEL: ${{ env.SLACK_CHANNEL }} - AWS_BUCKET: ${{ env.AWS_BUCKET }} + NODE_VERSION: ${{ vars.NODE_VERSION }} + SLACK_CHANNEL: ${{ vars.SLACK_CHANNEL }} + AWS_BUCKET: ${{ vars.PROD_AWS_BUCKET_ARTIFACT }} secrets: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} AWS_KEY_ID: ${{ secrets.TEST_AWS_KEY_ID }} diff --git a/web/static-s3/github/web-s3-realease-production-deploy-cicd.yml b/web/static-s3/github/web-s3-realease-production-deploy-cicd.yml index 56d6bd4..4fc5157 100644 --- a/web/static-s3/github/web-s3-realease-production-deploy-cicd.yml +++ b/web/static-s3/github/web-s3-realease-production-deploy-cicd.yml @@ -6,23 +6,17 @@ on: types: [published] -env: - SLACK_CHANNEL: ${{ vars.SLACK_CHANNEL }} - AWS_BUCKET: ${{ vars.PROD_AWS_BUCKET }} - AWS_BUCKET_ARTIFACT: ${{ vars.PROD_AWS_BUCKET_ARTIFACT }} - jobs: production: uses: steplix/cicd-steplix/.github/workflows/web-s3-release-deploy.yml@feature/addStaticWebWorkflows with: - NODE_VERSION: ${{ env.NODE_VERSION }} - AWS_BUCKET: ${{ env.AWS_BUCKET }} - AWS_BUCKET_ARTIFACT: ${{ env.AWS_BUCKET_ARTIFACT }} - SLACK_CHANNEL: ${{ env.SLACK_CHANNEL }} + AWS_BUCKET: ${{ vars.PROD_AWS_BUCKET }} + AWS_BUCKET_ARTIFACT: ${{ vars.PROD_AWS_BUCKET_ARTIFACT }} + SLACK_CHANNEL: ${{ vars.SLACK_CHANNEL }} + AWS_CLOUDFRONT_DISTRIBUTION_ID: ${{ vars.PROD_AWS_CLOUDFRONT_DISTRIBUTION_ID }} secrets: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} AWS_KEY_ID: ${{ secrets.PROD_AWS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.PROD_AWS_SECRET_ACCESS_KEY }} AWS_REGION: ${{ secrets.PROD_AWS_REGION }} - AWS_CLOUDFRONT_DISTRIBUTION_ID: ${{ vars.PROD_AWS_CLOUDFRONT_DISTRIBUTION_ID }} diff --git a/web/static-s3/github/web-s3-testing-deploy-cicd.yml b/web/static-s3/github/web-s3-testing-deploy-cicd.yml index cfc81bc..308c05c 100644 --- a/web/static-s3/github/web-s3-testing-deploy-cicd.yml +++ b/web/static-s3/github/web-s3-testing-deploy-cicd.yml @@ -6,25 +6,20 @@ on: branches: - testing -env: - NODE_VERSION: ${{ vars.NODE_VERSION }} - DESTINATION_PR: ${{ vars.DESTINATION_PR_ON_TESTING_WORKFLOW }} - PR_TITLE: " is TAG VERSION INCREMENT: PUSHING testing INTO ${{ vars.DESTINATION_PR_ON_TESTING_WORKFLOW }}" - SLACK_CHANNEL: ${{ vars.SLACK_CHANNEL }} - AWS_BUCKET: ${{ vars.TEST_AWS_BUCKET }} jobs: testing: uses: steplix/cicd-steplix/.github/workflows/web-s3-testing-deploy.yml@feature/addStaticWebWorkflows with: - NODE_VERSION: ${{ env.NODE_VERSION }} - DESTINATION_PR: ${{ env.DESTINATION_PR }} - PR_TITLE: ${{ env.PR_TITLE }} - SLACK_CHANNEL: ${{ env.SLACK_CHANNEL }} + NODE_VERSION: ${{ vars.NODE_VERSION }} + DESTINATION_PR: ${{ vars.DESTINATION_PR_ON_TESTING_WORKFLOW }} + PR_TITLE: " is TAG VERSION INCREMENT: PUSHING testing INTO ${{ vars.DESTINATION_PR_ON_TESTING_WORKFLOW }}" + SLACK_CHANNEL: ${{ vars.SLACK_CHANNEL }} + AWS_BUCKET: ${{ vars.TEST_AWS_BUCKET }} + AWS_CLOUDFRONT_DISTRIBUTION_ID: ${{ vars.TEST_AWS_CLOUDFRONT_DISTRIBUTION_ID }} secrets: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} AWS_KEY_ID: ${{ secrets.TEST_AWS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.TEST_AWS_SECRET_ACCESS_KEY }} AWS_REGION: ${{ secrets.TEST_AWS_REGION }} - AWS_CLOUDFRONT_DISTRIBUTION_ID: ${{ vars.TEST_AWS_CLOUDFRONT_DISTRIBUTION_ID }} From 3fa4e95088472f7541a229a7f074e06f20c457ea Mon Sep 17 00:00:00 2001 From: leandro Date: Fri, 21 Apr 2023 15:48:02 +0200 Subject: [PATCH 14/44] fix --- .github/workflows/web-s3-release-deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/web-s3-release-deploy.yml b/.github/workflows/web-s3-release-deploy.yml index a840c65..e6c211f 100644 --- a/.github/workflows/web-s3-release-deploy.yml +++ b/.github/workflows/web-s3-release-deploy.yml @@ -59,7 +59,7 @@ jobs: #UPLOAD - uses: aws-actions/configure-aws-credentials@v1.7.0 with: - aws-access-key-id: ${{ secrets.PROD_AWS_KEY_ID }} + aws-access-key-id: ${{ secrets.AWS_KEY_ID }} aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} aws-region: ${{ secrets.AWS_REGION }} - name: copy files to S3 From aef5c39281b4147473fec0b8482b35ac775d53d0 Mon Sep 17 00:00:00 2001 From: leandro Date: Mon, 24 Apr 2023 17:00:08 +0200 Subject: [PATCH 15/44] test --- .github/workflows/web-s3-release-deploy.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/web-s3-release-deploy.yml b/.github/workflows/web-s3-release-deploy.yml index e6c211f..56c6de8 100644 --- a/.github/workflows/web-s3-release-deploy.yml +++ b/.github/workflows/web-s3-release-deploy.yml @@ -57,11 +57,7 @@ jobs: run: tar -xvzf ${{ github.event.release.tag_name }}.tar.gz -C output #UPLOAD - - uses: aws-actions/configure-aws-credentials@v1.7.0 - with: - aws-access-key-id: ${{ secrets.AWS_KEY_ID }} - aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - aws-region: ${{ secrets.AWS_REGION }} + - name: copy files to S3 run: | aws s3 sync output s3://${{ inputs.AWS_BUCKET }} From f8084681b9692a639ace6c4e7f2f162340a99d60 Mon Sep 17 00:00:00 2001 From: leandro Date: Tue, 25 Apr 2023 19:00:10 +0200 Subject: [PATCH 16/44] fix event --- web/static-s3/github/web-s3-production-push-cicd.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/web/static-s3/github/web-s3-production-push-cicd.yml b/web/static-s3/github/web-s3-production-push-cicd.yml index 55aaf62..43a5b49 100644 --- a/web/static-s3/github/web-s3-production-push-cicd.yml +++ b/web/static-s3/github/web-s3-production-push-cicd.yml @@ -3,7 +3,9 @@ run-name: > ${{ github.event.pull_request.title }} on: - push: + pull_request_target: + types: + - closed branches: - master @@ -16,8 +18,11 @@ jobs: NODE_VERSION: ${{ vars.NODE_VERSION }} SLACK_CHANNEL: ${{ vars.SLACK_CHANNEL }} AWS_BUCKET: ${{ vars.PROD_AWS_BUCKET_ARTIFACT }} + TEXT-WHERE-SEARCH-FOR-PARAMETERS: ${{ github.event.pull_request.title }} + secrets: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} AWS_KEY_ID: ${{ secrets.TEST_AWS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.TEST_AWS_SECRET_ACCESS_KEY }} AWS_REGION: ${{ secrets.TEST_AWS_REGION }} + From 59320013266e67d4a57a0e3193bde666345fd8ca Mon Sep 17 00:00:00 2001 From: Federico Grennon Date: Wed, 15 Feb 2023 12:24:13 -0300 Subject: [PATCH 17/44] adding package publish pipes --- .github/workflows/ms-develop-validate.yml | 34 ------ .github/workflows/pkg-develop-validate.yml | 89 ++++++++++++++++ .github/workflows/pkg-publish.yml | 114 +++++++++++++++++++++ 3 files changed, 203 insertions(+), 34 deletions(-) create mode 100644 .github/workflows/pkg-develop-validate.yml create mode 100644 .github/workflows/pkg-publish.yml diff --git a/.github/workflows/ms-develop-validate.yml b/.github/workflows/ms-develop-validate.yml index 8e5c24f..d8f7c12 100644 --- a/.github/workflows/ms-develop-validate.yml +++ b/.github/workflows/ms-develop-validate.yml @@ -76,12 +76,6 @@ jobs: steps: - uses: actions/checkout@v3 - - uses: steplix/cicd-check-parameter@1.0.0 - id: args - with: - message: ${{ env.COMMIT_MESSAGE }} - param-0: automerge-testing - - name: Create Testing Pull Request id: pr uses: repo-sync/pull-request@v2 @@ -90,21 +84,8 @@ jobs: pr_title: "Testing deployment: ${{ env.COMMIT_MESSAGE }}" pr_body: Automated PR github_token: ${{ env.GITHUB_TOKEN }} - - - name: Auto-merge Pull Request - if: ${{ steps.args.outputs.param-0 == 'true' }} - env: - GH_TOKEN: ${{ github.token }} - run: gh pr merge "${{ steps.pr.outputs.pr_url }}" --merge - - - name: Trigger testing workflow - if: ${{ steps.args.outputs.param-0 == 'true' }} - env: - GH_TOKEN: ${{ github.token }} - run: gh workflow run testing-deploy.yml --ref testing --field commit-message="${{ env.COMMIT_MESSAGE }}" - name: Notify Slack - if: ${{ steps.args.outputs.param-0 != 'true' }} uses: steplix/cicd-notify@1.0.0 continue-on-error: true with: @@ -114,18 +95,3 @@ jobs: env: PR_URL: ${{ steps.pr.outputs.pr_url }} PR_NUMBER: ${{ steps.pr.outputs.pr_number }} - - notify-failure: - runs-on: ubuntu-latest - needs: - - validate - - create-pr - if: failure() - continue-on-error: true - steps: - - name: Slack Notify - uses: steplix/cicd-notify@1.0.0 - with: - template: push - status: failure - channel: ${{ inputs.SLACK_CHANNEL }} diff --git a/.github/workflows/pkg-develop-validate.yml b/.github/workflows/pkg-develop-validate.yml new file mode 100644 index 0000000..bd4979e --- /dev/null +++ b/.github/workflows/pkg-develop-validate.yml @@ -0,0 +1,89 @@ +name: Development validation + +on: + workflow_call: + inputs: + COMMIT_MESSAGE: + type: string + description: "Pass the head commit message {{ github.event.head_commit.message }}" + required: true + PR_BRANCH: + type: string + default: testing + description: Branch to generate PR to finish the pipeline + required: false + NODE_VERSION: + type: string + default: '18' + required: false + DISABLE_CACHE: + type: string + default: 'false' + description: Disable package.json cache + required: false + SLACK_CHANNEL: + type: string + description: Slack channel to send notifications + required: false + secrets: + SLACK_WEBHOOK_URL: + required: true + +env: + COMMIT_MESSAGE: '${{ inputs.COMMIT_MESSAGE }}' + PR_BRANCH: '${{ inputs.PR_BRANCH }}' + NODE_VERSION: '${{ inputs.NODE_VERSION }}' + DISABLE_CACHE: '${{ inputs.DISABLE_CACHE }}' + SLACK_CHANNEL: '${{ inputs.SLACK_CHANNEL }}' + SLACK_WEBHOOK_URL: '${{ secrets.SLACK_WEBHOOK }}' + +jobs: + validate: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: ${{ env.NODE_VERSION }} + + - name: Cache dependencies + if: env.DISABLE_CACHE != 'true' + id: cache + uses: actions/cache@v3 + with: + path: ./node_modules + key: modules-${{ hashFiles('package-lock.json') }} + + - name: Install dependencies + if: (steps.cache.outputs.cache-hit != 'true') + run: npm ci --ignore-scripts + + - run: npm run build --if-present + - run: npm run lint --if-present + - run: npm run test --if-present + + create-pr: + runs-on: ubuntu-latest + needs: validate + steps: + - uses: actions/checkout@v3 + + - name: Create Pull Request + id: pr + uses: repo-sync/pull-request@v2 + with: + destination_branch: ${{ env.PR_BRANCH }} + pr_title: "Publish package: ${{ env.COMMIT_MESSAGE }}" + pr_body: Automated PR + github_token: ${{ secrets.GITHUB_TOKEN }} + + - name: Notify Slack + uses: steplix/cicd-notify@1.0.0 + continue-on-error: true + with: + template: pr + status: ${{ job.status }} + channel: ${{ inputs.SLACK_CHANNEL }} + env: + PR_URL: ${{ steps.pr.outputs.pr_url }} + PR_NUMBER: ${{ steps.pr.outputs.pr_number }} diff --git a/.github/workflows/pkg-publish.yml b/.github/workflows/pkg-publish.yml new file mode 100644 index 0000000..9f62eb0 --- /dev/null +++ b/.github/workflows/pkg-publish.yml @@ -0,0 +1,114 @@ +name: Publish package + +on: + workflow_call: + inputs: + NODE_VERSION: + type: string + default: '18' + required: false + SLACK_CHANNEL: + type: string + description: Slack channel to send notifications + required: false + secrets: + SLACK_WEBHOOK_URL: + required: true + NPM_TOKEN: + required: true + +env: + NPM_TOKEN: '${{ secrets.NPM_TOKEN }}' + NODE_VERSION: '${{ vars.NODE_VERSION }}' + SLACK_CHANNEL: '${{ vars.SLACK_CHANNEL }}' + SLACK_WEBHOOK_URL: '${{ secrets.SLACK_WEBHOOK }}' + +jobs: + pre-tag: + runs-on: ubuntu-latest + steps: + - uses: steplix/cicd-check-parameter@1.0.0 + id: args + with: + param-0: major + param-1: minor + + - uses: actions/checkout@v3 + + - name: Get bumping mode + id: bump + run: echo "mode=${{ (steps.args.outputs.param-0 == 'true' && 'major') || (steps.args.outputs.param-1 == 'true' && 'minor') || 'patch' }}" >> $GITHUB_OUTPUT + + - name: Get tag + uses: zwaldowski/semver-release-action@v3 + id: new-tag + with: + bump: ${{ steps.bump.outputs.mode }} + github_token: ${{ secrets.GITHUB_TOKEN }} + dry_run: true + outputs: + version: ${{ steps.new-tag.outputs.version }} + skip-deploy: ${{ steps.args.outputs.param-2 }} + + publish: + runs-on: ubuntu-latest + needs: pre-tag + steps: + - uses: actions/checkout@v3 + + - uses: actions/setup-node@v3 + with: + node-version: ${{ env.NODE_VERSION }} + registry-url: https://registry.npmjs.org + + - run: npm ci --ignore-scripts + + - name: Modify package.json based on bumped tag + shell: bash + run: | + echo sed -i 's/\"version\":\s*\"[0-9]+\.[0-9]+\.[0-9]+\",\"version\": \"${{ needs.pre-tag.outputs.version }}\"/g' package.json + + - run: npm publish + env: + NODE_AUTH_TOKEN: ${{ env.NPM_TOKEN }} + + tag: + runs-on: ubuntu-latest + needs: + - pre-tag + - publish + steps: + - uses: steplix/cicd-check-parameter@1.0.0 + id: args + with: + param-0: major + param-1: minor + + - uses: actions/checkout@v3 + + - name: Get bumping mode + id: bump + run: echo "mode=${{ (steps.args.outputs.param-0 == 'true' && 'major') || (steps.args.outputs.param-1 == 'true' && 'minor') || 'patch' }}" >> $GITHUB_OUTPUT + + - name: Tagging + uses: zwaldowski/semver-release-action@v3 + id: new-tag + with: + bump: ${{ steps.bump.outputs.mode }} + github_token: ${{ env.GITHUB_TOKEN }} + + notify-failure: + runs-on: ubuntu-latest + needs: + - pre-tag + - publish + - tag + if: failure() + continue-on-error: true + steps: + - name: Slack Notify + uses: steplix/cicd-notify@1.0.0 + with: + template: push + status: failure + channel: ${{ env.SLACK_CHANNEL }} From fc6239362cf99e8c11a0da43af0afd713aedb4fc Mon Sep 17 00:00:00 2001 From: Federico Grennon Date: Wed, 15 Feb 2023 12:28:42 -0300 Subject: [PATCH 18/44] adding templates for publish npm --- npm/develop-validate.yml | 21 +++++++++++++++++++++ npm/publish-package.yml | 19 +++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 npm/develop-validate.yml create mode 100644 npm/publish-package.yml diff --git a/npm/develop-validate.yml b/npm/develop-validate.yml new file mode 100644 index 0000000..e4e0400 --- /dev/null +++ b/npm/develop-validate.yml @@ -0,0 +1,21 @@ +name: 1. Development validation + +run-name: > + Develop validate: ${{ github.event.head_commit.message }} + +on: + push: + branches: + - develop + +jobs: + develop: + uses: steplix/cicd-steplix/.github/workflows/pkg-develop-validate.yml@main + with: + COMMIT_MESSAGE: ${{ github.event.head_commit.message }} + PR_BRANCH: master + NODE_VERSION: '${{ vars.NODE_VERSION }}' + DISABLE_CACHE: '${{ vars.DISABLE_NODE_CACHE }}' + SLACK_CHANNEL: '${{ vars.SLACK_CHANNEL }}' + secrets: + SLACK_WEBHOOK_URL: '${{ secrets.SLACK_WEBHOOK }}' diff --git a/npm/publish-package.yml b/npm/publish-package.yml new file mode 100644 index 0000000..93e8028 --- /dev/null +++ b/npm/publish-package.yml @@ -0,0 +1,19 @@ +name: 1. Publish package + +run-name: > + Publish package: ${{ github.event.head_commit.message }} + +on: + push: + branches: + - master + +jobs: + master: + uses: steplix/cicd-steplix/.github/workflows/pkg-publish.yml@main + with: + NODE_VERSION: '${{ vars.NODE_VERSION }}' + SLACK_CHANNEL: '${{ vars.SLACK_CHANNEL }}' + secrets: + SLACK_WEBHOOK_URL: '${{ secrets.SLACK_WEBHOOK }}' + NPM_TOKEN: '${{ secrets.NPM_TOKEN }}' From 5e8fae974f552f56fb192be9630aeaa75921bd1a Mon Sep 17 00:00:00 2001 From: Federico Grennon Date: Wed, 15 Feb 2023 12:46:07 -0300 Subject: [PATCH 19/44] fixing publish npm --- .github/workflows/pkg-develop-validate.yml | 4 ++-- .github/workflows/pkg-publish.yml | 8 ++++---- npm/publish-package.yml | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/pkg-develop-validate.yml b/.github/workflows/pkg-develop-validate.yml index bd4979e..9b2b1f4 100644 --- a/.github/workflows/pkg-develop-validate.yml +++ b/.github/workflows/pkg-develop-validate.yml @@ -14,7 +14,7 @@ on: required: false NODE_VERSION: type: string - default: '18' + default: '18.x' required: false DISABLE_CACHE: type: string @@ -35,7 +35,7 @@ env: NODE_VERSION: '${{ inputs.NODE_VERSION }}' DISABLE_CACHE: '${{ inputs.DISABLE_CACHE }}' SLACK_CHANNEL: '${{ inputs.SLACK_CHANNEL }}' - SLACK_WEBHOOK_URL: '${{ secrets.SLACK_WEBHOOK }}' + SLACK_WEBHOOK_URL: '${{ secrets.SLACK_WEBHOOK_URL }}' jobs: validate: diff --git a/.github/workflows/pkg-publish.yml b/.github/workflows/pkg-publish.yml index 9f62eb0..a5019b2 100644 --- a/.github/workflows/pkg-publish.yml +++ b/.github/workflows/pkg-publish.yml @@ -5,7 +5,7 @@ on: inputs: NODE_VERSION: type: string - default: '18' + default: '18.x' required: false SLACK_CHANNEL: type: string @@ -18,10 +18,10 @@ on: required: true env: + NODE_VERSION: '${{ inputs.NODE_VERSION }}' + SLACK_CHANNEL: '${{ inputs.SLACK_CHANNEL }}' + SLACK_WEBHOOK_URL: '${{ secrets.SLACK_WEBHOOK_URL }}' NPM_TOKEN: '${{ secrets.NPM_TOKEN }}' - NODE_VERSION: '${{ vars.NODE_VERSION }}' - SLACK_CHANNEL: '${{ vars.SLACK_CHANNEL }}' - SLACK_WEBHOOK_URL: '${{ secrets.SLACK_WEBHOOK }}' jobs: pre-tag: diff --git a/npm/publish-package.yml b/npm/publish-package.yml index 93e8028..502bf5d 100644 --- a/npm/publish-package.yml +++ b/npm/publish-package.yml @@ -1,4 +1,4 @@ -name: 1. Publish package +name: 2. Publish package run-name: > Publish package: ${{ github.event.head_commit.message }} From fe3d06965a34b967f0ec87633e23e66033a01e7f Mon Sep 17 00:00:00 2001 From: Federico Grennon Date: Wed, 15 Feb 2023 12:56:55 -0300 Subject: [PATCH 20/44] fix update package.json in publish npm --- .github/workflows/pkg-publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pkg-publish.yml b/.github/workflows/pkg-publish.yml index a5019b2..5e751b9 100644 --- a/.github/workflows/pkg-publish.yml +++ b/.github/workflows/pkg-publish.yml @@ -66,7 +66,7 @@ jobs: - name: Modify package.json based on bumped tag shell: bash run: | - echo sed -i 's/\"version\":\s*\"[0-9]+\.[0-9]+\.[0-9]+\",\"version\": \"${{ needs.pre-tag.outputs.version }}\"/g' package.json + sed -i'' 's/"version": "[0-9]*\.[0-9]*\.[0-9]*"/"version": "${{ needs.pre-tag.outputs.version }}"/g' package.json - run: npm publish env: From 1e72360094ce78b7bb67f95c65ca25cdecc24651 Mon Sep 17 00:00:00 2001 From: Federico Grennon Date: Wed, 15 Feb 2023 13:17:19 -0300 Subject: [PATCH 21/44] fix publish npm flow --- .github/workflows/pkg-publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pkg-publish.yml b/.github/workflows/pkg-publish.yml index 5e751b9..bbc6e7c 100644 --- a/.github/workflows/pkg-publish.yml +++ b/.github/workflows/pkg-publish.yml @@ -68,7 +68,7 @@ jobs: run: | sed -i'' 's/"version": "[0-9]*\.[0-9]*\.[0-9]*"/"version": "${{ needs.pre-tag.outputs.version }}"/g' package.json - - run: npm publish + - run: npm publish --access public --tag ${{ needs.pre-tag.outputs.version }} env: NODE_AUTH_TOKEN: ${{ env.NPM_TOKEN }} From ebf3487d506470cad5f883ec2138254f817932c3 Mon Sep 17 00:00:00 2001 From: Federico Grennon Date: Wed, 15 Feb 2023 13:19:45 -0300 Subject: [PATCH 22/44] fix publish npm flow --- .github/workflows/pkg-publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pkg-publish.yml b/.github/workflows/pkg-publish.yml index bbc6e7c..8849c20 100644 --- a/.github/workflows/pkg-publish.yml +++ b/.github/workflows/pkg-publish.yml @@ -68,7 +68,7 @@ jobs: run: | sed -i'' 's/"version": "[0-9]*\.[0-9]*\.[0-9]*"/"version": "${{ needs.pre-tag.outputs.version }}"/g' package.json - - run: npm publish --access public --tag ${{ needs.pre-tag.outputs.version }} + - run: npm publish --access public env: NODE_AUTH_TOKEN: ${{ env.NPM_TOKEN }} From 52bf15992000f98a3eb94794c07c60f87a1b56b6 Mon Sep 17 00:00:00 2001 From: Federico Grennon Date: Wed, 15 Feb 2023 13:26:13 -0300 Subject: [PATCH 23/44] fix tag in publish npm flow --- .github/workflows/pkg-publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pkg-publish.yml b/.github/workflows/pkg-publish.yml index 8849c20..f0b6870 100644 --- a/.github/workflows/pkg-publish.yml +++ b/.github/workflows/pkg-publish.yml @@ -95,7 +95,7 @@ jobs: id: new-tag with: bump: ${{ steps.bump.outputs.mode }} - github_token: ${{ env.GITHUB_TOKEN }} + github_token: ${{ secrets.GITHUB_TOKEN }} notify-failure: runs-on: ubuntu-latest From d924dbb409c012aa1007c37bb7f355343c0d1da9 Mon Sep 17 00:00:00 2001 From: Santiago Nobili Date: Mon, 10 Apr 2023 09:15:03 -0300 Subject: [PATCH 24/44] bitbucket scripts --- .../bitbucket/scripts/create-mr.sh | 38 +++++++++++++++++++ .../bitbucket/scripts/get-new-tag.sh | 20 ++++++++++ .../bitbucket/scripts/merge-mr.sh | 22 +++++++++++ .../bitbucket/scripts/ssp-to-json.sh | 30 +++++++++++++++ 4 files changed, 110 insertions(+) create mode 100644 aws/ecr-cloudformation/bitbucket/scripts/create-mr.sh create mode 100644 aws/ecr-cloudformation/bitbucket/scripts/get-new-tag.sh create mode 100644 aws/ecr-cloudformation/bitbucket/scripts/merge-mr.sh create mode 100644 aws/ecr-cloudformation/bitbucket/scripts/ssp-to-json.sh diff --git a/aws/ecr-cloudformation/bitbucket/scripts/create-mr.sh b/aws/ecr-cloudformation/bitbucket/scripts/create-mr.sh new file mode 100644 index 0000000..34fe835 --- /dev/null +++ b/aws/ecr-cloudformation/bitbucket/scripts/create-mr.sh @@ -0,0 +1,38 @@ +#!/bin/bash +HEAD_COMMIT_MESSAGE=$(git log --format=%B -n 1) +CURRENT_BRANCH=$(git branch --show-current) + +SOURCE_BRANCH=${2:-$CURRENT_BRANCH} + +printf -v BODY '{ + "title": "%s", + "description": "", + "source": { + "branch": { + "name": "%s" + } + }, + "destination": { + "branch": { + "name": "%s" + } + }, + "close_source_branch": false, + "reviewers": '[]' + }' "$HEAD_COMMIT_MESSAGE" "$SOURCE_BRANCH" "$1" + +RESPONSE=$(curl https://api.bitbucket.org/2.0/repositories/$BITBUCKET_WORKSPACE/$BITBUCKET_REPO_SLUG/pullrequests \ + -s -S -X POST \ + -H 'Content-Type: application/json' \ + -H "Authorization: Bearer $BB_BEARER" \ + -d "$BODY") + +MRID=$(echo $RESPONSE | jq '.id') + +if [ "$MRID" = "null" ]; then + >&2 echo "Error creating MR" + >&2 echo $RESPONSE + exit 1 +fi + +echo $MRID diff --git a/aws/ecr-cloudformation/bitbucket/scripts/get-new-tag.sh b/aws/ecr-cloudformation/bitbucket/scripts/get-new-tag.sh new file mode 100644 index 0000000..d17c5ba --- /dev/null +++ b/aws/ecr-cloudformation/bitbucket/scripts/get-new-tag.sh @@ -0,0 +1,20 @@ +#!/bin/bash +HEAD_COMMIT_MESSAGE=$(git log --format=%B -n 1) + +TAG_ID=$(git rev-list --tags --max-count=1) +if [[ -z "$TAG_ID" ]]; then + git fetch --all --tags + TAG_ID=$(git rev-list --tags --max-count=1) +fi + +LAST_TAG=$(if [[ -z "$TAG_ID" ]]; then echo "0.0.0"; else echo $(git describe --tags ${TAG_ID}); fi) + +if [[ "$HEAD_COMMIT_MESSAGE" == *#major* ]]; then + VERSION=$(echo "${LAST_TAG}" | awk -F. -v OFS=. '{$1 += 1; print $1".0.0"}'); +elif [[ "$HEAD_COMMIT_MESSAGE" == *#minor* ]]; then + VERSION=$(echo "${LAST_TAG}" | awk -F. -v OFS=. '{$2 += 1; print $1"."$2".0"}'); +else + VERSION=$(echo "${LAST_TAG}" | awk -F. -v OFS=. '{$3 += 1 ; print}'); +fi + +echo "$VERSION" \ No newline at end of file diff --git a/aws/ecr-cloudformation/bitbucket/scripts/merge-mr.sh b/aws/ecr-cloudformation/bitbucket/scripts/merge-mr.sh new file mode 100644 index 0000000..7bb144c --- /dev/null +++ b/aws/ecr-cloudformation/bitbucket/scripts/merge-mr.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +printf -v BODY '{ + "type": "todo", + "message": "Automated merge #%s", + "close_source_branch": false + }' "$BITBUCKET_BUILD_NUMBER" + + +RESPONSE=$(curl https://api.bitbucket.org/2.0/repositories/$BITBUCKET_WORKSPACE/$BITBUCKET_REPO_SLUG/pullrequests/$1/merge \ + -s -S -X POST \ + -H 'Content-Type: application/json' \ + -H "Authorization: Bearer $BB_BEARER" \ + -d "$BODY") + +if [ "$(echo $RESPONSE | jq -r '.type')" = "error" ]; then + >&2 echo "Error merging MR" + >&2 echo $RESPONSE + exit 1 +fi + +echo $RESPONSE \ No newline at end of file diff --git a/aws/ecr-cloudformation/bitbucket/scripts/ssp-to-json.sh b/aws/ecr-cloudformation/bitbucket/scripts/ssp-to-json.sh new file mode 100644 index 0000000..c0f416b --- /dev/null +++ b/aws/ecr-cloudformation/bitbucket/scripts/ssp-to-json.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +# initialize an empty array to hold the json objects +JSON_ARRAY=() + +# loop through each argument and create a json object +for arg in "$@"; do + + ArrArray=$(echo "$arg" | tr ' ' '\n') + for kvalue in "${ArrArray[@]}"; do + + # split argument into key and value + IFS='=' read -ra KV <<< "$kvalue" + key=${KV[0]} + value=${KV[1]} + + # add json object to array + JSON_ARRAY+=("{\"ParameterKey\": \"$key\", \"ParameterValue\": \"$value\"}") + JSON_ARRAY+=(",") + + done +done + +# remove the last comma +JSON_ARRAY=("${JSON_ARRAY[@]::${#JSON_ARRAY[@]}-1}") +# join the json objects with commas and enclose in brackets to create a json array +JSON_STRING="[${JSON_ARRAY[*]}]" + +# print the json array +echo "$JSON_STRING" \ No newline at end of file From caa078a0d4eeadd1b455f33957a68cd472fb7148 Mon Sep 17 00:00:00 2001 From: Santiago Nobili Date: Mon, 10 Apr 2023 11:00:12 -0300 Subject: [PATCH 25/44] final bb pipeline --- .../bitbucket/bitbucket-pipelines.yml | 239 ++++++++++++++++++ 1 file changed, 239 insertions(+) create mode 100644 aws/ecr-cloudformation/bitbucket/bitbucket-pipelines.yml diff --git a/aws/ecr-cloudformation/bitbucket/bitbucket-pipelines.yml b/aws/ecr-cloudformation/bitbucket/bitbucket-pipelines.yml new file mode 100644 index 0000000..dd5ebfb --- /dev/null +++ b/aws/ecr-cloudformation/bitbucket/bitbucket-pipelines.yml @@ -0,0 +1,239 @@ +# NodeJs ECR Docker Cloudformation deploy + +options: + max-time: 20 + +pipelines: + custom: + # Always has to be master branch + production-deployment: + - variables: + - name: DeployTag + default: "latest" + - stage: + name: Deploy to production + deployment: production + steps: + - step: + name: Deploy tag to AWS CloudFormation + image: alpine:3.17.3 + script: + - apk add bash jq git aws-cli + - git fetch --tags + - > + if [ $DeployTag == "latest" ]; then + echo "Deploying latest tag" + TAG_ID=$(git rev-list --tags --max-count=1) + TAG=$(if [ -z "$TAG_ID" ]; then echo "0.0.0"; else echo $(git describe --tags ${TAG_ID}); fi) + else + if [ $(git tag -l "$DeployTag") ]; then + TAG=$DeployTag + else + echo "Tag $DeployTag does not exist" + exit 1 + fi + fi + - echo "Deploying $TAG" + - STACK_NAME=${ENV_AWS_ECS_NAME:-$BITBUCKET_REPO_SLUG}-production + + - PARAMS_OVERRIDE=($(echo "$AWS_CLOUDFORMATION_PARAMS_OVERRIDE" | tr ' ' '\n')) + - JSON_PARAMS_OVERRIDE=$(wget -qO - 'https://raw.githubusercontent.com/steplix/cicd-steplix/main/aws/ecr-cloudformation/bitbucket/scripts/ssp-to-json.sh' | bash -s Environment=production ParameterSuffix=Production EnvAwsECRImage=${AWS_ECR_REPOSITORY}:${TAG} ${PARAMS_OVERRIDE[@]}) + + - pipe: atlassian/aws-cloudformation-deploy:0.15.2 + variables: + STACK_NAME: $STACK_NAME + TEMPLATE: './cloudformation/cloudformation.yml' + + STACK_PARAMETERS: $JSON_PARAMS_OVERRIDE + + WITH_DEFAULT_TAGS: 'false' + + WAIT: 'true' + WAIT_INTERVAL: 10 + DEBUG: 'true' + branches: + develop: + - step: + image: node:12 + name: Build and Test + caches: + - node + script: + - npm install + - npm run lint --if-present + - npm run test --if-present + - step: + name: Create Testing MR + image: alpine:3.17.3 + script: + - apk add curl bash jq git + - HEAD_COMMIT_MESSAGE=$(git log --format=%B -n 1) + - echo $HEAD_COMMIT_MESSAGE + + - git checkout -b develop-testing + - git merge develop + - git push origin + - TESTING_MR_ID=$(wget -qO - 'https://raw.githubusercontent.com/steplix/cicd-steplix/main/aws/ecr-cloudformation/bitbucket/scripts/create-mr.sh' | bash -s testing develop-testing) + - > + echo "${HEAD_COMMIT_MESSAGE}" | grep -q "#automerge-testing" && echo "trigger automerge" && wget -qO - 'https://raw.githubusercontent.com/steplix/cicd-steplix/main/aws/ecr-cloudformation/bitbucket/scripts/merge-mr.sh' | bash -s $TESTING_MR_ID + + hotfix/*: + - step: + image: node:12 + name: Build and Test + caches: + - node + script: + - npm install + - npm run lint --if-present + - npm test --if-present + - step: + name: Create Master MR + image: alpine:3.17.3 + script: + - apk add curl bash jq git + - HEAD_COMMIT_MESSAGE=$(git log --format=%B -n 1) + + - DEVELOP_MR_ID=$(wget -qO - 'https://raw.githubusercontent.com/steplix/cicd-steplix/main/aws/ecr-cloudformation/bitbucket/scripts/create-mr.sh' | bash -s develop) + - MASTER_MR_ID=$(wget -qO - 'https://raw.githubusercontent.com/steplix/cicd-steplix/main/aws/ecr-cloudformation/bitbucket/scripts/create-mr.sh' | bash -s master) + - echo "${HEAD_COMMIT_MESSAGE}" | grep -q "#automerge-master" && echo "trigger automerge master" && wget -qO - 'https://raw.githubusercontent.com/steplix/cicd-steplix/main/aws/ecr-cloudformation/bitbucket/scripts/merge-mr.sh' | bash -s $MASTER_MR_ID + - echo "${HEAD_COMMIT_MESSAGE}" | grep -q "#automerge-develop" && echo "trigger automerge develop" && wget -qO - 'https://raw.githubusercontent.com/steplix/cicd-steplix/main/aws/ecr-cloudformation/bitbucket/scripts/merge-mr.sh' | bash -s $DEVELOP_MR_ID + + testing: + - stage: + name: Deploy to testing + deployment: testing + steps: + - step: + name: Build docker; push to ECR + image: amazon/aws-cli:2.11.8 + services: + - docker + script: + # Installing and running awscli for docker build because of registry caches + - export DOCKER_BUILDKIT=1 + + - REGISTRY_ACCOUNT_ID=${ECR_ACCOUNT_ID:-$AWS_ACCOUNT_ID} + - REGISTRY_REGION=${ECR_DEFAULT_REGION:-$AWS_DEFAULT_REGION} + + - ACCOUNT_ID=$(aws sts get-caller-identity --query "Account" --output text) + - DOCKER_URL=$REGISTRY_ACCOUNT_ID.dkr.ecr.$REGISTRY_REGION.amazonaws.com/${AWS_ECR_REPOSITORY} + + - TAG="${BITBUCKET_COMMIT}" + + # Commenting to avoid minute usage + + - aws ecr get-login-password --region "${AWS_DEFAULT_REGION}" | docker login --username AWS --password-stdin ${DOCKER_URL} + - LATEST=$(aws ecr describe-images --repository-name ${AWS_ECR_REPOSITORY} --query 'sort_by(imageDetails,& imagePushedAt)[-1].imageTags[0]' --output text) + + # # https://github.com/moby/buildkit/issues/2274#issuecomment-1378849271 + # - docker pull ${DOCKER_URL}:${BITBUCKET_COMMIT} || true + + # Replace tag in package.json version + - | + sed -i "s/\"version\":\s*\"[0-9]\+\.[0-9]\+\.[0-9]\+\"/\"version\": \"$TAG\"/g" package.json + + - docker build --cache-from=${DOCKER_URL}:${LATEST} --tag ${DOCKER_URL}:${TAG} --build-arg BUILDKIT_INLINE_CACHE=1 . + - docker push ${DOCKER_URL}:${TAG} + - step: + name: Deploy AWS CloudFormation + script: + - echo $DEPL + - STACK_NAME=${ENV_AWS_ECS_NAME:-$BITBUCKET_REPO_SLUG}-testing + + # Commenting to avoid minute usage + - PARAMS_OVERRIDE=($(echo "$AWS_CLOUDFORMATION_PARAMS_OVERRIDE" | tr ' ' '\n')) + - JSON_PARAMS_OVERRIDE=$(wget -qO - 'https://raw.githubusercontent.com/steplix/cicd-steplix/main/aws/ecr-cloudformation/bitbucket/scripts/ssp-to-json.sh' | bash -s Environment=testing ParameterSuffix=Testing EnvAwsECRImage=${AWS_ECR_REPOSITORY}:${BITBUCKET_COMMIT} ${PARAMS_OVERRIDE[@]}) + + - echo $PARAMS_OVERRIDE + - echo $JSON_PARAMS_OVERRIDE + + - pipe: atlassian/aws-cloudformation-deploy:0.15.2 + variables: + STACK_NAME: $STACK_NAME + TEMPLATE: './cloudformation/cloudformation.yml' + STACK_PARAMETERS: $JSON_PARAMS_OVERRIDE + WITH_DEFAULT_TAGS: 'false' + + WAIT: 'true' + WAIT_INTERVAL: 10 + + DEBUG: 'true' + - step: + image: alpine:3.17.3 + name: Create Master MR + script: + - apk add curl bash jq git + - MASTER_MR_ID=$(wget -qO - 'https://raw.githubusercontent.com/steplix/cicd-steplix/main/aws/ecr-cloudformation/bitbucket/scripts/create-mr.sh' | bash -s master) + - echo "${HEAD_COMMIT_MESSAGE}" | grep -q "#automerge-master" && echo "trigger automerge" && wget -qO - 'https://raw.githubusercontent.com/steplix/cicd-steplix/main/aws/ecr-cloudformation/bitbucket/scripts/merge-mr.sh' | bash -s $MASTER_MR_ID + + master: + - stage: + name: Deploy to staging + deployment: staging + steps: + - step: + name: Build tagged docker; push to ECR + image: alpine:3.17.3 + services: + - docker + script: + - apk add bash jq git aws-cli + - TAG=$(wget -qO - 'https://raw.githubusercontent.com/steplix/cicd-steplix/main/aws/ecr-cloudformation/bitbucket/scripts/get-new-tag.sh' | bash -s) + - echo $TAG + + # Installing and running awscli for docker build because of registry caches + - export DOCKER_BUILDKIT=1 + + - REGISTRY_ACCOUNT_ID=${ECR_ACCOUNT_ID:-$AWS_ACCOUNT_ID} + - REGISTRY_REGION=${ECR_DEFAULT_REGION:-$AWS_DEFAULT_REGION} + + - ACCOUNT_ID=$(aws sts get-caller-identity --query "Account" --output text) + - DOCKER_URL=$REGISTRY_ACCOUNT_ID.dkr.ecr.$REGISTRY_REGION.amazonaws.com/${AWS_ECR_REPOSITORY} + + + - aws ecr get-login-password --region "${AWS_DEFAULT_REGION}" | docker login --username AWS --password-stdin ${DOCKER_URL} + - LATEST=$(aws ecr describe-images --repository-name ${AWS_ECR_REPOSITORY} --query 'sort_by(imageDetails,& imagePushedAt)[-1].imageTags[0]' --output text) + + - | + sed -i "s/\"version\":\s*\"[0-9]\+\.[0-9]\+\.[0-9]\+\"/\"version\": \"$TAG\"/g" package.json + + - docker build --cache-from=${DOCKER_URL}:${LATEST} --tag ${DOCKER_URL}:${TAG} --build-arg BUILDKIT_INLINE_CACHE=1 . + - docker push ${DOCKER_URL}:${TAG} + - step: + name: Deploy AWS CloudFormation + image: alpine:3.17.3 + script: + - apk add bash jq git aws-cli + - TAG=$(wget -qO - 'https://raw.githubusercontent.com/steplix/cicd-steplix/main/aws/ecr-cloudformation/bitbucket/scripts/get-new-tag.sh' | bash -s ) + - echo $TAG + + - STACK_NAME=${ENV_AWS_ECS_NAME:-$BITBUCKET_REPO_SLUG}-staging + - echo $STACK_NAME + # - read -a PARAMS_OVERRIDE <<< "$AWS_CLOUDFORMATION_PARAMS_OVERRIDE" + - PRE_TEST=$(echo "$AWS_CLOUDFORMATION_PARAMS_OVERRIDE" | tr ' ' '\n') + # - PARAMS_OVERRIDE=($(echo "$AWS_CLOUDFORMATION_PARAMS_OVERRIDE" | tr ' ' '\n')) + - echo $PARAMS_OVERRIDE + - JSON_PARAMS_OVERRIDE=$(wget -qO - 'https://raw.githubusercontent.com/steplix/cicd-steplix/main/aws/ecr-cloudformation/bitbucket/scripts/ssp-to-json.sh' | bash -s Environment=staging ParameterSuffix=Staging EnvAwsECRImage=${AWS_ECR_REPOSITORY}:${TAG} ${AWS_CLOUDFORMATION_PARAMS_OVERRIDE}) + - echo $JSON_PARAMS_OVERRIDE + + - pipe: atlassian/aws-cloudformation-deploy:0.15.2 + variables: + STACK_NAME: $STACK_NAME + TEMPLATE: './cloudformation/cloudformation.yml' + STACK_PARAMETERS: $JSON_PARAMS_OVERRIDE + WITH_DEFAULT_TAGS: 'false' + + WAIT: 'true' + WAIT_INTERVAL: 10 + + DEBUG: 'true' + - step: + name: Create Release + image: alpine:3.17.3 + script: + - apk add bash jq git + - TAG=$(wget -qO - 'https://raw.githubusercontent.com/steplix/cicd-steplix/main/aws/ecr-cloudformation/bitbucket/scripts/get-new-tag.sh' | bash -s) + - git tag $TAG + - git push origin --tags + From 2f519b71f24ca762f7b6b0796679f25533fec001 Mon Sep 17 00:00:00 2001 From: Federico Grennon Date: Thu, 20 Apr 2023 14:57:54 -0300 Subject: [PATCH 26/44] Adding react native mobile pipelines --- .../mob-react-native-develop-validate.yml | 94 ++++++ .github/workflows/mob-react-native-hotfix.yml | 130 ++++++++ ...react-native-production-deploy-android.yml | 219 +++++++++++++ ...mob-react-native-production-deploy-ios.yml | 203 ++++++++++++ ...ob-react-native-staging-deploy-android.yml | 290 ++++++++++++++++++ .../mob-react-native-staging-deploy-ios.yml | 205 +++++++++++++ ...ob-react-native-testing-deploy-android.yml | 258 ++++++++++++++++ .../mob-react-native-testing-deploy-ios.yml | 209 +++++++++++++ mobile/react-native/develop-validate.yml | 18 ++ mobile/react-native/hotfix.yml | 19 ++ .../production-deploy-android.yml | 27 ++ mobile/react-native/production-deploy-ios.yml | 27 ++ .../react-native/staging-deploy-android.yml | 27 ++ mobile/react-native/staging-deploy-ios.yml | 27 ++ .../react-native/testing-deploy-android.yml | 28 ++ mobile/react-native/testing-deploy-ios.yml | 27 ++ 16 files changed, 1808 insertions(+) create mode 100644 .github/workflows/mob-react-native-develop-validate.yml create mode 100644 .github/workflows/mob-react-native-hotfix.yml create mode 100644 .github/workflows/mob-react-native-production-deploy-android.yml create mode 100644 .github/workflows/mob-react-native-production-deploy-ios.yml create mode 100644 .github/workflows/mob-react-native-staging-deploy-android.yml create mode 100644 .github/workflows/mob-react-native-staging-deploy-ios.yml create mode 100644 .github/workflows/mob-react-native-testing-deploy-android.yml create mode 100644 .github/workflows/mob-react-native-testing-deploy-ios.yml create mode 100644 mobile/react-native/develop-validate.yml create mode 100644 mobile/react-native/hotfix.yml create mode 100644 mobile/react-native/production-deploy-android.yml create mode 100644 mobile/react-native/production-deploy-ios.yml create mode 100644 mobile/react-native/staging-deploy-android.yml create mode 100644 mobile/react-native/staging-deploy-ios.yml create mode 100644 mobile/react-native/testing-deploy-android.yml create mode 100644 mobile/react-native/testing-deploy-ios.yml diff --git a/.github/workflows/mob-react-native-develop-validate.yml b/.github/workflows/mob-react-native-develop-validate.yml new file mode 100644 index 0000000..f6117f8 --- /dev/null +++ b/.github/workflows/mob-react-native-develop-validate.yml @@ -0,0 +1,94 @@ +name: Development validation + +on: + workflow_call: + inputs: + COMMIT_MESSAGE: + type: string + description: "Pass the head commit message {{ github.event.head_commit.message }}" + required: true + PR_BRANCH: + type: string + default: testing + description: Branch to generate PR to finish the pipeline + required: false + NODE_VERSION: + type: string + default: '18' + required: false + DISABLE_CACHE: + type: string + default: 'false' + SLACK_CHANNEL: + type: string + secrets: + SLACK_WEBHOOK_URL: + required: true + +env: + NEXT_BRANCH: '${{ inputs.PR_BRANCH }}' + COMMIT_MESSAGE: '${{ inputs.COMMIT_MESSAGE }}' + NODE_VERSION: '${{ inputs.NODE_VERSION }}' + DISABLE_CACHE: '${{ inputs.DISABLE_CACHE }}' + SLACK_CHANNEL: '${{ inputs.SLACK_CHANNEL }}' + + # Secrets + SLACK_WEBHOOK_URL: '${{ secrets.SLACK_WEBHOOK_URL }}' + GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}' + +jobs: + validate: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - uses: actions/setup-node@v3 + with: + node-version: ${{ env.NODE_VERSION }} + + - uses: steplix/cicd-check-parameter@1.0.0 + id: args + with: + message: ${{ env.COMMIT_MESSAGE }} + param-0: no-cache + + - name: Cache dependencies + if: steps.args.outputs.param-0 != 'true' && env.DISABLE_CACHE != 'true' + id: cache + uses: actions/cache@v3 + with: + path: ./node_modules + key: modules-${{ hashFiles('package-lock.json') }} + + - name: Install dependencies + if: (steps.cache.outputs.cache-hit != 'true') + run: npm ci --ignore-scripts + + - run: npm run lint --if-present + - run: npm run test --if-present + + create-pr: + runs-on: ubuntu-latest + needs: validate + steps: + - uses: actions/checkout@v3 + + - name: Create Testing Pull Request + id: pr + uses: repo-sync/pull-request@v2 + with: + destination_branch: "${{ env.NEXT_BRANCH }}" + pr_title: "Testing deployment: ${{ env.COMMIT_MESSAGE }}" + pr_body: Automated PR + github_token: ${{ env.GITHUB_TOKEN }} + + - name: Notify Slack + uses: steplix/cicd-notify@1.0.0 + continue-on-error: true + with: + template: pr + status: ${{ job.status }} + channel: ${{ env.SLACK_CHANNEL }} + env: + PR_URL: ${{ steps.pr.outputs.pr_url }} + PR_NUMBER: ${{ steps.pr.outputs.pr_number }} diff --git a/.github/workflows/mob-react-native-hotfix.yml b/.github/workflows/mob-react-native-hotfix.yml new file mode 100644 index 0000000..f2cd68b --- /dev/null +++ b/.github/workflows/mob-react-native-hotfix.yml @@ -0,0 +1,130 @@ +name: Development validation + +on: + workflow_call: + inputs: + COMMIT_MESSAGE: + type: string + description: "Pass the head commit message {{ github.event.head_commit.message }}" + required: true + MAIN_BRANCH: + type: string + default: master + description: Main branch + required: false + DEVELOP_BRANCH: + type: string + default: develop + description: Development branch + required: false + NODE_VERSION: + type: string + default: '18' + required: false + DISABLE_CACHE: + type: string + default: 'false' + SLACK_CHANNEL: + type: string + secrets: + SLACK_WEBHOOK_URL: + required: true + +env: + MAIN_BRANCH: '${{ inputs.MAIN_BRANCH }}' + DEVELOP_BRANCH: '${{ inputs.DEVELOP_BRANCH }}' + COMMIT_MESSAGE: '${{ inputs.COMMIT_MESSAGE }}' + NODE_VERSION: '${{ inputs.NODE_VERSION }}' + DISABLE_CACHE: '${{ inputs.DISABLE_CACHE }}' + SLACK_CHANNEL: '${{ inputs.SLACK_CHANNEL }}' + + # Secrets + SLACK_WEBHOOK_URL: '${{ secrets.SLACK_WEBHOOK_URL }}' + GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}' + +jobs: + validate: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - uses: actions/setup-node@v3 + with: + node-version: ${{ env.NODE_VERSION }} + + - uses: steplix/cicd-check-parameter@1.0.0 + id: args + with: + message: ${{ env.COMMIT_MESSAGE }} + param-0: no-cache + + - name: Cache dependencies + if: steps.args.outputs.param-0 != 'true' && env.DISABLE_CACHE != 'true' + id: cache + uses: actions/cache@v3 + with: + path: ./node_modules + key: modules-${{ hashFiles('package-lock.json') }} + + - name: Install dependencies + if: (steps.cache.outputs.cache-hit != 'true') + run: npm ci --ignore-scripts + + - run: npm run lint --if-present + - run: npm run test --if-present + + create-pr: + runs-on: ubuntu-latest + needs: validate + steps: + - uses: actions/checkout@v3 + + # Main pull request + - name: Create ${{ env.MAIN_BRANCH }} Pull Request + uses: repo-sync/pull-request@v2 + id: main-pr + with: + source_branch: "${{ github.ref_name }}" + destination_branch: "${{ env.MAIN_BRANCH }}" + pr_title: "Hotfix deployment: ${{ github.ref }} #skip-deploy" + pr_body: | + Automated PR + github_token: ${{ env.GITHUB_TOKEN }} + + # Develop pull request + - name: Create ${{ env.DEVELOP_BRANCH }} Pull Request + uses: repo-sync/pull-request@v2 + id: develop-pr + with: + source_branch: "${{ github.ref_name }}" + destination_branch: "${{ env.DEVELOP_BRANCH }}" + pr_title: "Hotfix retro-merge: ${{ github.ref }} [skip ci]" + pr_body: | + Automated PR -- Merge as soon as possible, otherwise the staging deployment may be blocked + github_token: ${{ env.GITHUB_TOKEN }} + + - name: Notify Slack + uses: steplix/cicd-notify@1.0.0 + continue-on-error: true + with: + template: pr + status: ${{ job.status }} + channel: ${{ env.SLACK_CHANNEL }} + env: + PR_URL: ${{ steps.main-pr.outputs.pr_url }} + PR_NUMBER: ${{ steps.main-pr.outputs.pr_number }} + + notify-failure: + runs-on: ubuntu-latest + needs: + - validate + - create-pr + if: failure() + continue-on-error: true + steps: + - name: Slack Notify + uses: steplix/cicd-notify@1.0.0 + with: + template: push + status: failure + channel: ${{ env.SLACK_CHANNEL }} diff --git a/.github/workflows/mob-react-native-production-deploy-android.yml b/.github/workflows/mob-react-native-production-deploy-android.yml new file mode 100644 index 0000000..3acc135 --- /dev/null +++ b/.github/workflows/mob-react-native-production-deploy-android.yml @@ -0,0 +1,219 @@ +name: Firebase deployment + +# Variables needed setted in testing environment +# AWS_BUCKET +# GRADLE_ENV_NAME +# ENV_VARIABLES +# ENV_FILE_NAME +# ANDROID_PACKAGE_NAME + +on: + workflow_call: + inputs: + RELEASE_TAG: + type: string + description: Tag + required: true + ANDROID_KEYSTORE_NAME: + type: string + required: true + NODE_VERSION: + type: string + default: '18' + required: false + DISABLE_CACHE: + type: string + default: 'false' + required: false + SLACK_CHANNEL: + type: string + required: false + VERSION_CODE_OFFSET: + type: number + default: 0 + required: false + GRADLE_VERSION: + type: string + default: release-candidate + required: false + secrets: + SLACK_WEBHOOK_URL: + required: true + + # ANDROID + ANDROID_KEYSTORE_BASE64: + required: true + ANDROID_KEYSTORE_PASSWORD: + required: true + ANDROID_KEY_ALIAS: + required: true + ANDROID_KEY_PASSWORD: + required: true + ANDROID_SERVICE_ACCOUNT: + required: true + + AWS_ACCESS_KEY_ID: + required: true + AWS_SECRET_ACCESS_KEY: + required: true + AWS_REGION: + required: true + +env: + RELEASE_TAG: '${{ inputs.RELEASE_TAG }}' + + DISABLE_CACHE: '${{ inputs.DISABLE_CACHE }}' + SLACK_CHANNEL: '${{ inputs.SLACK_CHANNEL }}' + NODE_VERSION: '${{ inputs.NODE_VERSION }}' + VERSION_CODE_OFFSET: '${{ inputs.VERSION_CODE_OFFSET || 0 }}' + GRADLE_VERSION: '${{ inputs.GRADLE_VERSION }}' + + SLACK_WEBHOOK_URL: '${{ secrets.SLACK_WEBHOOK_URL }}' + GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}' + + # Android + ANDROID_KEYSTORE_NAME: '${{ inputs.ANDROID_KEYSTORE_NAME }}' + ANDROID_KEYSTORE_BASE64: '${{ secrets.ANDROID_KEYSTORE_BASE64 }}' + ANDROID_KEYSTORE_PASSWORD: '${{ secrets.ANDROID_KEYSTORE_PASSWORD }}' + ANDROID_KEY_ALIAS: '${{ secrets.ANDROID_KEY_ALIAS }}' + ANDROID_KEY_PASSWORD: '${{ secrets.ANDROID_KEY_PASSWORD }}' + ANDROID_SERVICE_ACCOUNT: '${{ secrets.ANDROID_SERVICE_ACCOUNT }}' + + ANDROID_OUTPUT_FILEPATH: 'android/app/build/outputs/bundle/${{ vars.GRADLE_ENV_NAME }}Release/app-${{ vars.GRADLE_ENV_NAME }}-release.aab' + +jobs: + deploy: + environment: production + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - uses: actions/setup-node@v3 + with: + node-version: ${{ env.NODE_VERSION }} + + - name: Cache dependencies + uses: actions/cache@v3 + if: env.DISABLE_CACHE != 'true' + id: cache + with: + path: ./node_modules + key: modules-${{ hashFiles('package-lock.json') }} + + - name: Install dependencies + if: (steps.cache.outputs.cache-hit != 'true') + run: npm ci --ignore-scripts + + - name: Calculate version code + shell: bash + env: + RUN_NUMBER: ${{ github.run_number }} + run: echo VERSION_CODE=$((${{ env.RUN_NUMBER }} + ${{ env.VERSION_CODE_OFFSET }})) >> $GITHUB_ENV + + - name: Bump version + uses: chkfung/android-version-actions@v1.2.1 + with: + gradlePath: android/app/build.gradle + versionCode: ${{ env.VERSION_CODE }} + versionName: ${{ env.RELEASE_TAG }} + + - name: Modify package.json based on bumped tag + shell: bash + run: | + echo sed -i 's/\"version\":\s*\"[0-9]+\.[0-9]+\.[0-9]+\",\"version\": \"${{ env.RELEASE_TAG }}\"/g' package.json + + - name: Create .env file + shell: bash + run: echo "${{ vars.ENV_VARIABLES }}" > ${{ vars.ENV_FILE_NAME }} + + - name: Capitalize gradle environment + id: CAPITALIZED_GRADLE_ENV + uses: ASzc/change-string-case-action@v5 + with: + string: ${{ vars.GRADLE_ENV_NAME }} + + - name: Decode Keystore + id: keystore + uses: timheuer/base64-to-file@v1.2 + with: + fileName: ${{ env.ANDROID_KEYSTORE_NAME }} + encodedString: ${{ secrets.ANDROID_KEYSTORE_BASE64 }} + + - name: Gradle cache + uses: actions/cache@v3 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + !~/.gradle/wrapper/dists/**/gradle*.zip + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }} + restore-keys: | + ${{ runner.os }}-gradle- + + - name: Gradle Setup + uses: gradle/gradle-build-action@v2.4.0 + with: + gradle-version: ${{ env.GRADLE_VERSION }} + build-root-directory: android/ + gradle-executable: android/ + + - name: Clean NDK + shell: bash + run: | + rm -rf /usr/local/lib/android/sdk/ndk + sed -i '/^ANDROID_NDK/d' ~/.bashrc + sed -i '/^ANDROID_NDK_HOME/d' ~/.bashrc + sed -i '/^ANDROID_NDK_LATEST_HOME/d' ~/.bashrc + sed -i '/^ANDROID_NDK_ROOT/d' ~/.bashrc + + - name: Build Android Release + run: cd android && ./gradlew bundle${{ env.GRADLE_ENV }}Release --no-daemon + env: + GRADLE_ENV: ${{ steps.CAPITALIZED_GRADLE_ENV.outputs.capitalized }} + SIGNING_STORE_PATH: ${{ steps.keystore.outputs.filePath }} + SIGNING_STORE_PASSWORD: ${{ env.ANDROID_KEYSTORE_PASSWORD }} + SIGNING_KEY_ALIAS: ${{ env.ANDROID_KEY_ALIAS }} + SIGNING_KEY_PASSWORD: ${{ env.ANDROID_KEY_PASSWORD }} + + - name: Get project name + uses: antifree/json-to-variables@v1.0.1 + with: + filename: app.json + prefix: app + + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v1.7.0 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ secrets.AWS_REGION }} + + - name: Upload artifact S3 + env: + FILE_NAME: '${{ vars.ANDROID_PACKAGE_NAME }}-${{ env.RELEASE_TAG }}.aab' + run: aws s3 cp ${{ env.ANDROID_OUTPUT_FILEPATH }} s3://${{ vars.AWS_BUCKET }}/${{ env.app_name }}/android/${{ env.FILE_NAME }} + + - name: Upload to Play store + uses: r0adkll/upload-google-play@v1 + with: + releaseFiles: ${{ env.ANDROID_OUTPUT_FILEPATH }} + serviceAccountJsonPlainText: ${{ env.ANDROID_SERVICE_ACCOUNT }} + packageName: ${{ vars.ANDROID_PACKAGE_NAME }} + track: internal + releaseName: ${{ env.RELEASE_TAG }} + status: completed + inAppUpdatePriority: 2 + + notify: + runs-on: ubuntu-latest + needs: + - deploy + if: success() || failure() + continue-on-error: true + steps: + - name: Slack Notify + uses: steplix/cicd-notify@1.0.0 + with: + template: push + status: failure + channel: ${{ env.SLACK_CHANNEL }} diff --git a/.github/workflows/mob-react-native-production-deploy-ios.yml b/.github/workflows/mob-react-native-production-deploy-ios.yml new file mode 100644 index 0000000..daf1787 --- /dev/null +++ b/.github/workflows/mob-react-native-production-deploy-ios.yml @@ -0,0 +1,203 @@ +name: Firebase deployment + +# Variables needed setted in testing environment +# AWS_BUCKET +# ENV_VARIABLES +# ENV_FILE_NAME +# IOS_PACKAGE_NAME +# IOS_SCHEMA + +on: + workflow_call: + inputs: + RELEASE_TAG: + type: string + description: Tag + required: true + PROJECT_PATH: + type: string + description: 'xcode project file path. Example: ios/project.xcodeproj' + required: true + WORKSPACE_PATH: + type: string + description: 'xcode workspace file path. Example: ios/project.xcworkspace' + required: true + NODE_VERSION: + type: string + default: '18' + required: false + DISABLE_CACHE: + type: string + default: 'false' + required: false + SLACK_CHANNEL: + type: string + required: false + RUBY_VERSION: + type: string + default: ruby + required: false + secrets: + SLACK_WEBHOOK_URL: + required: true + + # IOS + IOS_P12_BASE64: + required: true + IOS_MOBILE_PROVISION_BASE64: + required: true + IOS_TEAM_ID: + required: true + IOS_CERTIFICATE_PASSWORD: + required: true + IOS_APPSTORE_ISSUER_ID: + required: true + IOS_APPSTORE_API_KEY_ID: + required: true + IOS_APPSTORE_API_PRIVATE_KEY: + required: true + + AWS_ACCESS_KEY_ID: + required: true + AWS_SECRET_ACCESS_KEY: + required: true + AWS_REGION: + required: true + +env: + RELEASE_TAG: '${{ inputs.RELEASE_TAG }}' + + DISABLE_CACHE: '${{ inputs.DISABLE_CACHE }}' + SLACK_CHANNEL: '${{ inputs.SLACK_CHANNEL }}' + NODE_VERSION: '${{ inputs.NODE_VERSION }}' + RUBY_VERSION: '${{ inputs.RUBY_VERSION }}' + + SLACK_WEBHOOK_URL: '${{ secrets.SLACK_WEBHOOK_URL }}' + GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}' + + # IOS + IOS_P12_BASE64: '${{ secrets.IOS_P12_BASE64 }}' + IOS_MOBILE_PROVISION_BASE64: '${{ secrets.IOS_MOBILE_PROVISION_BASE64 }}' + IOS_TEAM_ID: '${{ secrets.IOS_TEAM_ID }}' + IOS_CERTIFICATE_PASSWORD: '${{ secrets.IOS_CERTIFICATE_PASSWORD }}' + IOS_APPSTORE_ISSUER_ID: '${{ secrets.IOS_APPSTORE_ISSUER_ID }}' + IOS_APPSTORE_API_KEY_ID: '${{ secrets.IOS_APPSTORE_API_KEY_ID }}' + IOS_APPSTORE_API_PRIVATE_KEY: '${{ secrets.IOS_APPSTORE_API_PRIVATE_KEY }}' + + IOS_OUTPUT_FILEPATH: output.ipa + +jobs: + deploy: + environment: production + runs-on: macos-latest + steps: + - uses: actions/checkout@v3 + + - uses: actions/setup-node@v3 + with: + node-version: ${{ env.NODE_VERSION }} + + - name: Cache dependencies + uses: actions/cache@v3 + if: env.DISABLE_CACHE != 'true' + id: cache + with: + path: ./node_modules + key: modules-${{ hashFiles('package-lock.json') }} + + - name: Install dependencies + if: (steps.cache.outputs.cache-hit != 'true') + run: npm ci --ignore-scripts + + - name: Bump version + uses: yanamura/ios-bump-version@v1.7.0 + with: + project-path: ios + version: ${{ env.RELEASE_TAG }} + build-number: 1 + + - name: Modify package.json based on bumped tag + shell: bash + run: | + echo sed -i 's/\"version\":\s*\"[0-9]+\.[0-9]+\.[0-9]+\",\"version\": \"${{ env.RELEASE_TAG }}\"/g' package.json + + - name: Create .env file + shell: bash + run: echo "${{ vars.ENV_VARIABLES }}" > ${{ vars.ENV_FILE_NAME }} + + - name: Get project name + uses: antifree/json-to-variables@v1.0.1 + with: + filename: app.json + prefix: app + + - name: Setup Ruby (bundle) + uses: ruby/setup-ruby@v1.144.0 + with: + ruby-version: ${{ env.RUBY_VERSION }} + bundler-cache: true + + - name: Restore Pods cache + uses: actions/cache@v3 + with: + path: | + ios/Pods + ~/Library/Caches/CocoaPods + ~/.cocoapods + key: ${{ runner.os }}-pods-${{ hashFiles('ios/Podfile.lock') }} + restore-keys: | + ${{ runner.os }}-pods- + + - name: Install Pods + run: cd ios && pod install --repo-update + + - name: Build React + run: npm run build:ios + + - name: Build IOS App + uses: yukiarrr/ios-build-action@v1.5.0 + with: + p12-base64: ${{ env.IOS_P12_BASE64 }} + mobileprovision-base64: ${{ env.IOS_MOBILE_PROVISION_BASE64 }} + team-id: ${{ env.IOS_TEAM_ID }} + certificate-password: ${{ env.IOS_CERTIFICATE_PASSWORD }} + code-signing-identity: iPhone Distribution + project-path: ${{ inputs.PROJECT_PATH }} + workspace-path: ${{ inputs.WORKSPACE_PATH }} + scheme: ${{ vars.IOS_SCHEMA }} + export-method: app-store + + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v1.7.0 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ secrets.AWS_REGION }} + + - name: Upload artifact S3 + shell: bash + env: + FILE_NAME: '${{ vars.IOS_PACKAGE_NAME }}-${{ env.RELEASE_TAG }}.ipa' + run: aws s3 cp ${{ env.IOS_OUTPUT_FILEPATH }} s3://${{ vars.AWS_BUCKET }}/${{ env.app_name }}/ios/${{ env.FILE_NAME }} + + - name: Upload app to TestFlight + uses: apple-actions/upload-testflight-build@v1 + with: + app-path: ${{ env.IOS_OUTPUT_FILEPATH }} + issuer-id: ${{ secrets.IOS_APPSTORE_ISSUER_ID }} + api-key-id: ${{ secrets.IOS_APPSTORE_API_KEY_ID }} + api-private-key: ${{ secrets.IOS_APPSTORE_API_PRIVATE_KEY }} + + notify: + runs-on: ubuntu-latest + needs: + - deploy + if: success() || failure() + continue-on-error: true + steps: + - name: Slack Notify + uses: steplix/cicd-notify@1.0.0 + with: + template: push + status: failure + channel: ${{ env.SLACK_CHANNEL }} diff --git a/.github/workflows/mob-react-native-staging-deploy-android.yml b/.github/workflows/mob-react-native-staging-deploy-android.yml new file mode 100644 index 0000000..c31bb00 --- /dev/null +++ b/.github/workflows/mob-react-native-staging-deploy-android.yml @@ -0,0 +1,290 @@ +name: Staging deployment + +# Variables needed setted in staging environment +# AWS_BUCKET +# GRADLE_ENV_NAME +# ENV_VARIABLES +# ENV_FILE_NAME +# ANDROID_PACKAGE_NAME +# ANDROID_FIREBASE_TESTER_GROUP + +on: + workflow_call: + inputs: + COMMIT_MESSAGE: + type: string + description: 'Pass the head commit message {{ github.event.head_commit.message }}' + required: true + ANDROID_KEYSTORE_NAME: + type: string + required: true + NODE_VERSION: + type: string + default: '18' + required: false + DISABLE_CACHE: + type: string + default: 'false' + required: false + SLACK_CHANNEL: + type: string + required: false + VERSION_CODE_OFFSET: + type: number + default: 0 + required: false + GRADLE_VERSION: + type: string + default: release-candidate + required: false + secrets: + SLACK_WEBHOOK_URL: + required: true + FIREBASE_TOKEN: + required: true + + # ANDROID + FIREBASE_ANDROID_APP_ID: + required: true + ANDROID_KEYSTORE_BASE64: + required: true + ANDROID_KEYSTORE_PASSWORD: + required: true + ANDROID_KEY_ALIAS: + required: true + ANDROID_KEY_PASSWORD: + required: true + + AWS_ACCESS_KEY_ID: + required: true + AWS_SECRET_ACCESS_KEY: + required: true + AWS_REGION: + required: true + +env: + COMMIT_MESSAGE: '${{ inputs.COMMIT_MESSAGE }}' + + DISABLE_CACHE: '${{ inputs.DISABLE_CACHE }}' + SLACK_CHANNEL: '${{ inputs.SLACK_CHANNEL }}' + NODE_VERSION: '${{ inputs.NODE_VERSION }}' + VERSION_CODE_OFFSET: '${{ inputs.VERSION_CODE_OFFSET || 0 }}' + GRADLE_VERSION: '${{ inputs.GRADLE_VERSION }}' + + SLACK_WEBHOOK_URL: '${{ secrets.SLACK_WEBHOOK_URL }}' + GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}' + FIREBASE_TOKEN: '${{ secrets.FIREBASE_TOKEN }}' + + # Android + FIREBASE_ANDROID_APP_ID: '${{ secrets.FIREBASE_ANDROID_APP_ID }}' + ANDROID_KEYSTORE_NAME: '${{ inputs.ANDROID_KEYSTORE_NAME }}' + ANDROID_KEYSTORE_BASE64: '${{ secrets.ANDROID_KEYSTORE_BASE64 }}' + ANDROID_KEYSTORE_PASSWORD: '${{ secrets.ANDROID_KEYSTORE_PASSWORD }}' + ANDROID_KEY_ALIAS: '${{ secrets.ANDROID_KEY_ALIAS }}' + ANDROID_KEY_PASSWORD: '${{ secrets.ANDROID_KEY_PASSWORD }}' + + ANDROID_OUTPUT_FILEPATH: android/app/build/outputs/apk/${{ vars.GRADLE_ENV_NAME }}/release/app-${{ vars.GRADLE_ENV_NAME }}-release.apk + +jobs: + pre-tag: + runs-on: ubuntu-latest + steps: + - uses: steplix/cicd-check-parameter@1.0.0 + id: args + with: + param-0: major + param-1: minor + param-2: skip-deploy + + - uses: actions/checkout@v3 + + - name: Get bumping mode + id: bump + run: echo "mode=${{ (steps.args.outputs.param-0 == 'true' && 'major') || (steps.args.outputs.param-1 == 'true' && 'minor') || 'patch' }}" >> $GITHUB_OUTPUT + + - name: Get tag + uses: zwaldowski/semver-release-action@v3 + id: new-tag + with: + bump: ${{ steps.bump.outputs.mode }} + github_token: ${{ env.GITHUB_TOKEN }} + dry_run: true + outputs: + version: ${{ steps.new-tag.outputs.version }} + skip-deploy: ${{ steps.args.outputs.param-2 }} + + deploy: + environment: staging + needs: + - pre-tag + if: needs.pre-tag.outputs.skip-deploy != 'true' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: TAG to environment + shell: bash + run: echo "TAG=${{ needs.pre-tag.outputs.version }}" >> $GITHUB_ENV; + + - uses: actions/setup-node@v3 + with: + node-version: ${{ env.NODE_VERSION }} + + - name: Cache dependencies + uses: actions/cache@v3 + if: env.DISABLE_CACHE != 'true' + id: cache + with: + path: ./node_modules + key: modules-${{ hashFiles('package-lock.json') }} + + - name: Install dependencies + if: (steps.cache.outputs.cache-hit != 'true') + run: npm ci --ignore-scripts + + - name: Calculate version code + shell: bash + env: + RUN_NUMBER: ${{ github.run_number }} + run: echo VERSION_CODE=$((${{ env.RUN_NUMBER }} + ${{ env.VERSION_CODE_OFFSET }})) >> $GITHUB_ENV + + - name: Bump version + uses: chkfung/android-version-actions@v1.2.1 + with: + gradlePath: android/app/build.gradle + versionCode: ${{ env.VERSION_CODE }} + versionName: ${{ env.TAG }} + + - name: Modify package.json based on bumped tag + shell: bash + run: | + echo sed -i 's/\"version\":\s*\"[0-9]+\.[0-9]+\.[0-9]+\",\"version\": \"${{ env.TAG }}\"/g' package.json + + - name: Create .env file + shell: bash + run: echo "${{ vars.ENV_VARIABLES }}" > ${{ vars.ENV_FILE_NAME }} + + - name: Capitalize gradle environment + id: CAPITALIZED_GRADLE_ENV + uses: ASzc/change-string-case-action@v5 + with: + string: ${{ vars.GRADLE_ENV_NAME }} + + - name: Decode Keystore + id: keystore + uses: timheuer/base64-to-file@v1.2 + with: + fileName: ${{ env.ANDROID_KEYSTORE_NAME }} + encodedString: ${{ secrets.ANDROID_KEYSTORE_BASE64 }} + + - name: Gradle cache + uses: actions/cache@v3 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + !~/.gradle/wrapper/dists/**/gradle*.zip + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }} + restore-keys: | + ${{ runner.os }}-gradle- + + - name: Gradle Setup + uses: gradle/gradle-build-action@v2.4.0 + with: + gradle-version: ${{ env.GRADLE_VERSION }} + build-root-directory: android/ + gradle-executable: android/ + + - name: Clean NDK + shell: bash + run: | + rm -rf /usr/local/lib/android/sdk/ndk + sed -i '/^ANDROID_NDK/d' ~/.bashrc + sed -i '/^ANDROID_NDK_HOME/d' ~/.bashrc + sed -i '/^ANDROID_NDK_LATEST_HOME/d' ~/.bashrc + sed -i '/^ANDROID_NDK_ROOT/d' ~/.bashrc + + - name: Build Android Release + run: cd android && ./gradlew assemble${{ env.GRADLE_ENV }}Release --no-daemon + env: + GRADLE_ENV: ${{ steps.CAPITALIZED_GRADLE_ENV.outputs.capitalized }} + SIGNING_STORE_PATH: ${{ steps.keystore.outputs.filePath }} + SIGNING_STORE_PASSWORD: ${{ env.ANDROID_KEYSTORE_PASSWORD }} + SIGNING_KEY_ALIAS: ${{ env.ANDROID_KEY_ALIAS }} + SIGNING_KEY_PASSWORD: ${{ env.ANDROID_KEY_PASSWORD }} + + - name: Get project name + uses: antifree/json-to-variables@v1.0.1 + with: + filename: app.json + prefix: app + + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v1.7.0 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ secrets.AWS_REGION }} + + - name: Upload artifact S3 + env: + S3_URI: s3://${{ vars.AWS_BUCKET }}/${{ env.app_name }}/android/${{ vars.ANDROID_PACKAGE_NAME }}-${{ env.TAG }}.apk + run: aws s3 cp ${{ env.ANDROID_OUTPUT_FILEPATH }} ${{ env.S3_URI }} + + - name: Upload Android artifact to Firebase App Distribution + uses: wzieba/Firebase-Distribution-Github-Action@v1.5.0 + with: + appId: ${{ env.FIREBASE_ANDROID_APP_ID }} + token: ${{ env.FIREBASE_TOKEN }} + groups: ${{ vars.ANDROID_FIREBASE_TESTER_GROUP }} + file: ${{ env.ANDROID_OUTPUT_FILEPATH }} + + tag: + runs-on: ubuntu-latest + needs: + - deploy + steps: + - uses: steplix/cicd-check-parameter@1.0.0 + id: args + with: + param-0: major + param-1: minor + + - uses: actions/checkout@v3 + + - name: Get bumping mode + id: bump + run: echo "mode=${{ (steps.args.outputs.param-0 == 'true' && 'major') || (steps.args.outputs.param-1 == 'true' && 'minor') || 'patch' }}" >> $GITHUB_OUTPUT + + - name: Tagging + uses: zwaldowski/semver-release-action@v3 + id: new-tag + with: + bump: ${{ steps.bump.outputs.mode }} + github_token: ${{ env.GITHUB_TOKEN }} + + - name: Notify Slack of new available release + continue-on-error: true + uses: steplix/cicd-notify@1.0.0 + with: + template: release + status: ${{ job.status }} + channel: ${{ env.SLACK_CHANNEL }} + env: + NEW_TAG: ${{ steps.new-tag.outputs.version }} + + notify-failure: + runs-on: ubuntu-latest + needs: + - pre-tag + - deploy + - tag + if: failure() + continue-on-error: true + steps: + - name: Slack Notify + uses: steplix/cicd-notify@1.0.0 + with: + template: push + status: failure + channel: ${{ env.SLACK_CHANNEL }} diff --git a/.github/workflows/mob-react-native-staging-deploy-ios.yml b/.github/workflows/mob-react-native-staging-deploy-ios.yml new file mode 100644 index 0000000..7f2ef62 --- /dev/null +++ b/.github/workflows/mob-react-native-staging-deploy-ios.yml @@ -0,0 +1,205 @@ +name: Staging deployment + +# Variables needed setted in testing environment +# AWS_BUCKET +# ENV_VARIABLES +# ENV_FILE_NAME +# IOS_PACKAGE_NAME +# IOS_SCHEMA +# IOS_FIREBASE_TESTER_GROUP + +on: + workflow_call: + inputs: + COMMIT_MESSAGE: + type: string + description: 'Pass the head commit message {{ github.event.head_commit.message }}' + required: true + TAG: + type: string + required: true + PROJECT_PATH: + type: string + description: 'xcode project file path. Example: ios/project.xcodeproj' + required: true + WORKSPACE_PATH: + type: string + description: 'xcode workspace file path. Example: ios/project.xcworkspace' + required: true + NODE_VERSION: + type: string + default: '18' + required: false + DISABLE_CACHE: + type: string + default: 'false' + required: false + SLACK_CHANNEL: + type: string + required: false + RUBY_VERSION: + type: string + default: ruby + required: false + secrets: + SLACK_WEBHOOK_URL: + required: true + FIREBASE_TOKEN: + required: true + + # IOS + FIREBASE_IOS_APP_ID: + required: true + IOS_P12_BASE64: + required: true + IOS_MOBILE_PROVISION_BASE64: + required: true + IOS_TEAM_ID: + required: true + IOS_CERTIFICATE_PASSWORD: + required: true + + AWS_ACCESS_KEY_ID: + required: true + AWS_SECRET_ACCESS_KEY: + required: true + AWS_REGION: + required: true + +env: + COMMIT_MESSAGE: '${{ inputs.COMMIT_MESSAGE }}' + + TAG: ${{ inputs.TAG }} + DISABLE_CACHE: '${{ inputs.DISABLE_CACHE }}' + SLACK_CHANNEL: '${{ inputs.SLACK_CHANNEL }}' + NODE_VERSION: '${{ inputs.NODE_VERSION }}' + RUBY_VERSION: '${{ inputs.RUBY_VERSION }}' + + SLACK_WEBHOOK_URL: '${{ secrets.SLACK_WEBHOOK_URL }}' + GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}' + FIREBASE_TOKEN: '${{ secrets.FIREBASE_TOKEN }}' + + # IOS + FIREBASE_IOS_APP_ID: '${{ secrets.FIREBASE_IOS_APP_ID }}' + IOS_P12_BASE64: '${{ secrets.IOS_P12_BASE64 }}' + IOS_MOBILE_PROVISION_BASE64: '${{ secrets.IOS_MOBILE_PROVISION_BASE64 }}' + IOS_TEAM_ID: '${{ secrets.IOS_TEAM_ID }}' + IOS_CERTIFICATE_PASSWORD: '${{ secrets.IOS_CERTIFICATE_PASSWORD }}' + + IOS_OUTPUT_FILEPATH: output.ipa + +jobs: + deploy: + environment: staging + runs-on: macos-latest + steps: + - uses: actions/checkout@v3 + + - uses: actions/setup-node@v3 + with: + node-version: ${{ env.NODE_VERSION }} + + - name: Cache dependencies + uses: actions/cache@v3 + if: env.DISABLE_CACHE != 'true' + id: cache + with: + path: ./node_modules + key: modules-${{ hashFiles('package-lock.json') }} + + - name: Install dependencies + if: (steps.cache.outputs.cache-hit != 'true') + run: npm ci --ignore-scripts + + - name: Bump version + uses: yanamura/ios-bump-version@v1.7.0 + with: + project-path: ios + version: ${{ env.TAG }} + build-number: 1 + + - name: Modify package.json based on bumped tag + shell: bash + run: | + echo sed -i 's/\"version\":\s*\"[0-9]+\.[0-9]+\.[0-9]+\",\"version\": \"${{ env.TAG }}\"/g' package.json + + - name: Create .env file + shell: bash + run: echo "${{ vars.ENV_VARIABLES }}" > ${{ vars.ENV_FILE_NAME }} + + - name: Get project name + uses: antifree/json-to-variables@v1.0.1 + with: + filename: app.json + prefix: app + + - name: Setup Ruby (bundle) + uses: ruby/setup-ruby@v1.144.0 + with: + ruby-version: ${{ env.RUBY_VERSION }} + bundler-cache: true + + - name: Restore Pods cache + uses: actions/cache@v3 + with: + path: | + ios/Pods + ~/Library/Caches/CocoaPods + ~/.cocoapods + key: ${{ runner.os }}-pods-${{ hashFiles('ios/Podfile.lock') }} + restore-keys: | + ${{ runner.os }}-pods- + + - name: Install Pods + run: cd ios && pod install --repo-update + + - name: Build React + run: npm run build:ios + + - name: Build IOS App + uses: yukiarrr/ios-build-action@v1.5.0 + with: + p12-base64: ${{ env.IOS_P12_BASE64 }} + mobileprovision-base64: ${{ env.IOS_MOBILE_PROVISION_BASE64 }} + team-id: ${{ env.IOS_TEAM_ID }} + certificate-password: ${{ env.IOS_CERTIFICATE_PASSWORD }} + code-signing-identity: iPhone Distribution + project-path: ${{ inputs.PROJECT_PATH }} + workspace-path: ${{ inputs.WORKSPACE_PATH }} + scheme: ${{ vars.IOS_SCHEMA }} + export-method: ad-hoc + + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v1.7.0 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ secrets.AWS_REGION }} + + - name: Upload artifact S3 + shell: bash + env: + S3_URI: s3://${{ vars.AWS_BUCKET }}/${{ env.app_name }}/ios/${{ vars.IOS_PACKAGE_NAME }}-${{ env.TAG }}.ipa + run: aws s3 cp ${{ env.IOS_OUTPUT_FILEPATH }} ${{ env.S3_URI }} + + - name: Upload iOS artifact to Firebase App Distribution + uses: wzieba/Firebase-Distribution-Github-Action@v1.5.0 + with: + appId: ${{ env.FIREBASE_IOS_APP_ID }} + token: ${{ env.FIREBASE_TOKEN }} + groups: ${{ vars.IOS_FIREBASE_TESTER_GROUP }} + file: ${{ env.IOS_OUTPUT_FILEPATH }} + + notify-failure: + runs-on: ubuntu-latest + needs: + - deploy + if: failure() + continue-on-error: true + steps: + - name: Slack Notify + uses: steplix/cicd-notify@1.0.0 + with: + template: push + status: failure + channel: ${{ env.SLACK_CHANNEL }} diff --git a/.github/workflows/mob-react-native-testing-deploy-android.yml b/.github/workflows/mob-react-native-testing-deploy-android.yml new file mode 100644 index 0000000..eaf3773 --- /dev/null +++ b/.github/workflows/mob-react-native-testing-deploy-android.yml @@ -0,0 +1,258 @@ +name: Testing deployment + +# Variables needed setted in staging environment +# AWS_BUCKET +# GRADLE_ENV_NAME +# ENV_VARIABLES +# ENV_FILE_NAME +# ANDROID_PACKAGE_NAME +# ANDROID_FIREBASE_TESTER_GROUP + +on: + workflow_call: + inputs: + COMMIT_MESSAGE: + type: string + description: 'Pass the head commit message {{ github.event.head_commit.message }}' + required: true + PR_BRANCH: + type: string + description: Branch to generate PR to finish the pipeline + required: true + ANDROID_KEYSTORE_NAME: + type: string + required: true + NODE_VERSION: + type: string + default: '18' + required: false + DISABLE_CACHE: + type: string + default: 'false' + required: false + SLACK_CHANNEL: + type: string + required: false + VERSION_CODE_OFFSET: + type: number + default: 0 + required: false + GRADLE_VERSION: + type: string + default: release-candidate + required: false + secrets: + SLACK_WEBHOOK_URL: + required: true + FIREBASE_TOKEN: + required: true + + # ANDROID + FIREBASE_ANDROID_APP_ID: + required: true + ANDROID_KEYSTORE_BASE64: + required: true + ANDROID_KEYSTORE_PASSWORD: + required: true + ANDROID_KEY_ALIAS: + required: true + ANDROID_KEY_PASSWORD: + required: true + + AWS_ACCESS_KEY_ID: + required: true + AWS_SECRET_ACCESS_KEY: + required: true + AWS_REGION: + required: true + +env: + COMMIT_MESSAGE: '${{ inputs.COMMIT_MESSAGE }}' + NEXT_BRANCH: '${{ inputs.PR_BRANCH }}' + + DISABLE_CACHE: '${{ inputs.DISABLE_CACHE }}' + SLACK_CHANNEL: '${{ inputs.SLACK_CHANNEL }}' + NODE_VERSION: '${{ inputs.NODE_VERSION }}' + GRADLE_VERSION: '${{ inputs.GRADLE_VERSION }}' + VERSION_CODE_OFFSET: '${{ inputs.VERSION_CODE_OFFSET || 0 }}' + + SLACK_WEBHOOK_URL: '${{ secrets.SLACK_WEBHOOK_URL }}' + GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}' + FIREBASE_TOKEN: '${{ secrets.FIREBASE_TOKEN }}' + + # Android + FIREBASE_ANDROID_APP_ID: '${{ secrets.FIREBASE_ANDROID_APP_ID }}' + ANDROID_KEYSTORE_NAME: '${{ inputs.ANDROID_KEYSTORE_NAME }}' + ANDROID_KEYSTORE_BASE64: '${{ secrets.ANDROID_KEYSTORE_BASE64 }}' + ANDROID_KEYSTORE_PASSWORD: '${{ secrets.ANDROID_KEYSTORE_PASSWORD }}' + ANDROID_KEY_ALIAS: '${{ secrets.ANDROID_KEY_ALIAS }}' + ANDROID_KEY_PASSWORD: '${{ secrets.ANDROID_KEY_PASSWORD }}' + + ANDROID_OUTPUT_FILEPATH: android/app/build/outputs/apk/${{ vars.GRADLE_ENV_NAME }}/release/app-${{ vars.GRADLE_ENV_NAME }}-release.apk + +jobs: + deploy: + environment: testing + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Get Short commit SHA + shell: bash + run: echo "TAG=$(git rev-parse --short HEAD)" >> $GITHUB_ENV; + + - uses: actions/setup-node@v3 + with: + node-version: ${{ env.NODE_VERSION }} + + - name: Cache dependencies + uses: actions/cache@v3 + if: env.DISABLE_CACHE != 'true' + id: cache + with: + path: ./node_modules + key: modules-${{ hashFiles('package-lock.json') }} + + - name: Install dependencies + if: (steps.cache.outputs.cache-hit != 'true') + run: npm ci --ignore-scripts + + - name: Calculate version code + shell: bash + env: + RUN_NUMBER: ${{ github.run_number }} + run: echo VERSION_CODE=$((${{ env.RUN_NUMBER }} + ${{ env.VERSION_CODE_OFFSET }})) >> $GITHUB_ENV + + - name: Bump version + uses: chkfung/android-version-actions@v1.2.1 + with: + gradlePath: android/app/build.gradle + versionCode: ${{ env.VERSION_CODE }} + versionName: ${{ env.TAG }} + + - name: Modify package.json based on bumped tag + shell: bash + run: | + echo sed -i 's/\"version\":\s*\"[0-9]+\.[0-9]+\.[0-9]+\",\"version\": \"${{ env.TAG }}\"/g' package.json + + - name: Create .env file + shell: bash + run: echo "${{ vars.ENV_VARIABLES }}" > ${{ vars.ENV_FILE_NAME }} + + - name: Get project name + uses: antifree/json-to-variables@v1.0.1 + with: + filename: app.json + prefix: app + + - name: Capitalize gradle environment + id: CAPITALIZED_GRADLE_ENV + uses: ASzc/change-string-case-action@v5 + with: + string: ${{ vars.GRADLE_ENV_NAME }} + + - name: Decode Keystore + id: keystore + uses: timheuer/base64-to-file@v1.2 + with: + fileName: ${{ env.ANDROID_KEYSTORE_NAME }} + encodedString: ${{ env.ANDROID_KEYSTORE_BASE64 }} + + - name: Gradle cache + uses: actions/cache@v3 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + !~/.gradle/wrapper/dists/**/gradle*.zip + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }} + restore-keys: | + ${{ runner.os }}-gradle- + + - name: Gradle Setup + uses: gradle/gradle-build-action@v2.4.0 + with: + gradle-version: ${{ env.GRADLE_VERSION }} + build-root-directory: android/ + gradle-executable: android/ + + - name: Clean NDK + shell: bash + run: | + rm -rf /usr/local/lib/android/sdk/ndk + sed -i '/^ANDROID_NDK/d' ~/.bashrc + sed -i '/^ANDROID_NDK_HOME/d' ~/.bashrc + sed -i '/^ANDROID_NDK_LATEST_HOME/d' ~/.bashrc + sed -i '/^ANDROID_NDK_ROOT/d' ~/.bashrc + + - name: Build Android Release + run: cd android && ./gradlew assemble${{ env.GRADLE_ENV }}Release --no-daemon + env: + GRADLE_ENV: ${{ steps.CAPITALIZED_GRADLE_ENV.outputs.capitalized }} + SIGNING_STORE_PATH: ${{ steps.keystore.outputs.filePath }} + SIGNING_STORE_PASSWORD: ${{ env.ANDROID_KEYSTORE_PASSWORD }} + SIGNING_KEY_ALIAS: ${{ env.ANDROID_KEY_ALIAS }} + SIGNING_KEY_PASSWORD: ${{ env.ANDROID_KEY_PASSWORD }} + + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v1.7.0 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ secrets.AWS_REGION }} + + - name: Upload artifact S3 + shell: bash + env: + S3_URI: s3://${{ vars.AWS_BUCKET }}/${{ env.app_name }}/android/${{ vars.ANDROID_PACKAGE_NAME }}.apk + run: aws s3 cp ${{ env.ANDROID_OUTPUT_FILEPATH }} ${{ env.S3_URI }} + + - name: Upload Android artifact to Firebase App Distribution + uses: wzieba/Firebase-Distribution-Github-Action@v1.5.0 + with: + appId: ${{ env.FIREBASE_ANDROID_APP_ID }} + token: ${{ env.FIREBASE_TOKEN }} + groups: ${{ vars.ANDROID_FIREBASE_TESTER_GROUP }} + file: ${{ env.ANDROID_OUTPUT_FILEPATH }} + + create-pr: + runs-on: ubuntu-latest + needs: + - deploy + steps: + - uses: actions/checkout@v3 + + - name: Create ${{ env.NEXT_BRANCH }} Pull Request + id: pr + uses: repo-sync/pull-request@v2 + with: + destination_branch: ${{ env.NEXT_BRANCH }} + pr_title: "Staging deployment: ${{ env.COMMIT_MESSAGE }}" + pr_body: Automated PR + github_token: ${{ env.GITHUB_TOKEN }} + + - name: Notify Slack + uses: steplix/cicd-notify@1.0.0 + continue-on-error: true + with: + template: pr + status: ${{ job.status }} + channel: ${{ env.SLACK_CHANNEL }} + env: + PR_URL: ${{ steps.pr.outputs.pr_url }} + PR_NUMBER: ${{ steps.pr.outputs.pr_number }} + + notify-failure: + runs-on: ubuntu-latest + needs: + - deploy + - create-pr + if: failure() + continue-on-error: true + steps: + - name: Slack Notify + uses: steplix/cicd-notify@1.0.0 + with: + template: push + status: failure + channel: ${{ env.SLACK_CHANNEL }} diff --git a/.github/workflows/mob-react-native-testing-deploy-ios.yml b/.github/workflows/mob-react-native-testing-deploy-ios.yml new file mode 100644 index 0000000..b1b08f9 --- /dev/null +++ b/.github/workflows/mob-react-native-testing-deploy-ios.yml @@ -0,0 +1,209 @@ +name: Testing deployment + +# Variables needed setted in testing environment +# AWS_BUCKET +# ENV_VARIABLES +# ENV_FILE_NAME +# IOS_PACKAGE_NAME +# IOS_SCHEMA +# IOS_FIREBASE_TESTER_GROUP + +on: + workflow_call: + inputs: + COMMIT_MESSAGE: + type: string + description: 'Pass the head commit message {{ github.event.head_commit.message }}' + required: true + PR_BRANCH: + type: string + description: Branch to generate PR to finish the pipeline + required: true + PROJECT_PATH: + type: string + description: 'xcode project file path. Example: ios/project.xcodeproj' + required: true + WORKSPACE_PATH: + type: string + description: 'xcode workspace file path. Example: ios/project.xcworkspace' + required: true + NODE_VERSION: + type: string + default: '18' + required: false + DISABLE_CACHE: + type: string + default: 'false' + required: false + SLACK_CHANNEL: + type: string + required: false + RUBY_VERSION: + type: string + default: ruby + required: false + secrets: + SLACK_WEBHOOK_URL: + required: true + FIREBASE_TOKEN: + required: true + + # IOS + FIREBASE_IOS_APP_ID: + required: true + IOS_P12_BASE64: + required: true + IOS_MOBILE_PROVISION_BASE64: + required: true + IOS_TEAM_ID: + required: true + IOS_CERTIFICATE_PASSWORD: + required: true + + AWS_ACCESS_KEY_ID: + required: true + AWS_SECRET_ACCESS_KEY: + required: true + AWS_REGION: + required: true + +env: + COMMIT_MESSAGE: '${{ inputs.COMMIT_MESSAGE }}' + NEXT_BRANCH: '${{ inputs.PR_BRANCH }}' + + DISABLE_CACHE: '${{ inputs.DISABLE_CACHE }}' + SLACK_CHANNEL: '${{ inputs.SLACK_CHANNEL }}' + NODE_VERSION: '${{ inputs.NODE_VERSION }}' + RUBY_VERSION: '${{ inputs.RUBY_VERSION }}' + + SLACK_WEBHOOK_URL: '${{ secrets.SLACK_WEBHOOK_URL }}' + FIREBASE_TOKEN: '${{ secrets.FIREBASE_TOKEN }}' + + # IOS + FIREBASE_IOS_APP_ID: '${{ secrets.FIREBASE_IOS_APP_ID }}' + IOS_P12_BASE64: '${{ secrets.IOS_P12_BASE64 }}' + IOS_MOBILE_PROVISION_BASE64: '${{ secrets.IOS_MOBILE_PROVISION_BASE64 }}' + IOS_TEAM_ID: '${{ secrets.IOS_TEAM_ID }}' + IOS_CERTIFICATE_PASSWORD: '${{ secrets.IOS_CERTIFICATE_PASSWORD }}' + + IOS_OUTPUT_FILEPATH: output.ipa + +jobs: + deploy: + environment: testing + runs-on: macos-latest + steps: + - uses: actions/checkout@v3 + + - name: Get Short commit SHA + shell: bash + run: echo "TAG=$(git rev-parse --short HEAD)" >> $GITHUB_ENV; + + - uses: actions/setup-node@v3 + with: + node-version: ${{ env.NODE_VERSION }} + + - name: Cache dependencies + uses: actions/cache@v3 + if: env.DISABLE_CACHE != 'true' + id: cache + with: + path: ./node_modules + key: modules-${{ hashFiles('package-lock.json') }} + + - name: Install dependencies + if: (steps.cache.outputs.cache-hit != 'true') + run: npm ci --ignore-scripts + + - name: Bump version + uses: yanamura/ios-bump-version@v1.7.0 + with: + project-path: ios + version: ${{ env.TAG }} + build-number: 1 + + - name: Modify package.json based on bumped tag + shell: bash + run: | + echo sed -i 's/\"version\":\s*\"[0-9]+\.[0-9]+\.[0-9]+\",\"version\": \"${{ env.TAG }}\"/g' package.json + + - name: Create .env file + shell: bash + run: echo "${{ vars.ENV_VARIABLES }}" > ${{ vars.ENV_FILE_NAME }} + + - name: Get project name + uses: antifree/json-to-variables@v1.0.1 + with: + filename: app.json + prefix: app + + - name: Setup Ruby (bundle) + uses: ruby/setup-ruby@v1.144.0 + with: + ruby-version: ${{ env.RUBY_VERSION }} + bundler-cache: true + + - name: Restore Pods cache + uses: actions/cache@v3 + with: + path: | + ios/Pods + ~/Library/Caches/CocoaPods + ~/.cocoapods + key: ${{ runner.os }}-pods-${{ hashFiles('ios/Podfile.lock') }} + restore-keys: | + ${{ runner.os }}-pods- + + - name: Install Pods + run: cd ios && pod install --repo-update + + - name: Build React + run: npm run build:ios + + - name: Build IOS App + uses: yukiarrr/ios-build-action@v1.5.0 + with: + p12-base64: ${{ env.IOS_P12_BASE64 }} + mobileprovision-base64: ${{ env.IOS_MOBILE_PROVISION_BASE64 }} + team-id: ${{ env.IOS_TEAM_ID }} + certificate-password: ${{ env.IOS_CERTIFICATE_PASSWORD }} + code-signing-identity: iPhone Distribution + project-path: ${{ inputs.PROJECT_PATH }} + workspace-path: ${{ inputs.WORKSPACE_PATH }} + scheme: ${{ vars.IOS_SCHEMA }} + export-method: ad-hoc + + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v1.7.0 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ secrets.AWS_REGION }} + + - name: Upload artifact S3 + shell: bash + env: + S3_URI: s3://${{ vars.AWS_BUCKET }}/${{ env.app_name }}/ios/${{ vars.IOS_PACKAGE_NAME }}.ipa + run: aws s3 cp ${{ env.IOS_OUTPUT_FILEPATH }} ${{ env.S3_URI }} + + - name: Upload iOS artifact to Firebase App Distribution + uses: wzieba/Firebase-Distribution-Github-Action@v1.5.0 + with: + appId: ${{ env.FIREBASE_IOS_APP_ID }} + token: ${{ env.FIREBASE_TOKEN }} + groups: ${{ vars.IOS_FIREBASE_TESTER_GROUP }} + file: ${{ env.IOS_OUTPUT_FILEPATH }} + + notify-failure: + runs-on: ubuntu-latest + needs: + - deploy + if: failure() + continue-on-error: true + steps: + - name: Slack Notify + uses: steplix/cicd-notify@1.0.0 + with: + template: push + status: failure + channel: ${{ env.SLACK_CHANNEL }} diff --git a/mobile/react-native/develop-validate.yml b/mobile/react-native/develop-validate.yml new file mode 100644 index 0000000..ff96f62 --- /dev/null +++ b/mobile/react-native/develop-validate.yml @@ -0,0 +1,18 @@ +name: 1. Development validation + +run-name: > + Develop validate: ${{ github.event.head_commit.message }} + +on: + push: + branches: + - develop + +jobs: + develop: + uses: steplix/cicd-steplix/.github/workflows/mob-react-native-develop-validate.yml@main + with: + COMMIT_MESSAGE: ${{ github.event.head_commit.message }} + PR_BRANCH: testing + secrets: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} diff --git a/mobile/react-native/hotfix.yml b/mobile/react-native/hotfix.yml new file mode 100644 index 0000000..20ec5a9 --- /dev/null +++ b/mobile/react-native/hotfix.yml @@ -0,0 +1,19 @@ +name: 2.b Hotfix validation + +run-name: > + Hotfix validation: ${{ github.event.head_commit.message }} + +on: + push: + branches: + - hotfix/** + +jobs: + hotfix: + uses: steplix/cicd-steplix/.github/workflows/mob-react-native-hotfix.yml@main + with: + COMMIT_MESSAGE: ${{ github.event.head_commit.message }} + MAIN_BRANCH: master + DEVELOP_BRANCH: develop + secrets: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} diff --git a/mobile/react-native/production-deploy-android.yml b/mobile/react-native/production-deploy-android.yml new file mode 100644 index 0000000..e0e520d --- /dev/null +++ b/mobile/react-native/production-deploy-android.yml @@ -0,0 +1,27 @@ +name: 6. Production Android Deployment + +run-name: > + Production Android deployment: ${{ github.event.release.tag_name }} + +on: + registry_package: + types: + - published + +jobs: + production-android: + if: contains(github.event.release.name, 'android') + uses: steplix/cicd-steplix/.github/workflows/mob-react-native-production-deploy-android.yml@main + with: + RELEASE_TAG: ${{ github.event.release.tag_name }} + ANDROID_KEYSTORE_NAME: ${{ vars.ANDROID_KEYSTORE_NAME }} + secrets: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + ANDROID_SERVICE_ACCOUNT: ${{ secrets.ANDROID_SERVICE_ACCOUNT }} + ANDROID_KEYSTORE_BASE64: ${{ secrets.ANDROID_KEYSTORE_BASE64 }} + ANDROID_KEYSTORE_PASSWORD: ${{ secrets.ANDROID_KEYSTORE_PASSWORD }} + ANDROID_KEY_ALIAS: ${{ secrets.ANDROID_KEY_ALIAS }} + ANDROID_KEY_PASSWORD: ${{ secrets.ANDROID_KEY_PASSWORD }} + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_REGION: ${{ secrets.AWS_REGION }} diff --git a/mobile/react-native/production-deploy-ios.yml b/mobile/react-native/production-deploy-ios.yml new file mode 100644 index 0000000..f27433c --- /dev/null +++ b/mobile/react-native/production-deploy-ios.yml @@ -0,0 +1,27 @@ +name: 7. Production iOS Deployment + +run-name: > + Production iOS deployment: ${{ github.event.release.tag_name }} + +on: + registry_package: + types: + - published + +jobs: + production-ios: + if: contains(github.event.release.name, 'ios') + uses: steplix/cicd-steplix/.github/workflows/mob-react-native-production-deploy-ios.yml@main + with: + RELEASE_TAG: ${{ github.event.release.tag_name }} + PROJECT_PATH: ios/project.xcodeproj + WORKSPACE_PATH: ios/project.xcworkspace + secrets: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_REGION: ${{ secrets.AWS_REGION }} + IOS_CERTIFICATE_PASSWORD: ${{ secrets.IOS_CERTIFICATE_PASSWORD }} + IOS_MOBILE_PROVISION_BASE64: ${{ secrets.IOS_MOBILE_PROVISION_BASE64 }} + IOS_P12_BASE64: ${{ secrets.IOS_P12_BASE64 }} + IOS_TEAM_ID: ${{ secrets.IOS_TEAM_ID }} \ No newline at end of file diff --git a/mobile/react-native/staging-deploy-android.yml b/mobile/react-native/staging-deploy-android.yml new file mode 100644 index 0000000..7bbd2a0 --- /dev/null +++ b/mobile/react-native/staging-deploy-android.yml @@ -0,0 +1,27 @@ +name: 4. Staging Android Deployment + +run-name: > + Staging Android deployment: ${{ github.event.head_commit.message }} + +on: + push: + branches: + - master + +jobs: + staging-android: + uses: steplix/cicd-steplix/.github/workflows/mob-react-native-staging-deploy-android.yml@main + with: + COMMIT_MESSAGE: ${{ github.event.head_commit.message }} + ANDROID_KEYSTORE_NAME: ${{ vars.ANDROID_KEYSTORE_NAME }} + secrets: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + FIREBASE_ANDROID_APP_ID: ${{ secrets.FIREBASE_ANDROID_APP_ID }} + FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }} + ANDROID_KEYSTORE_BASE64: ${{ secrets.ANDROID_KEYSTORE_BASE64 }} + ANDROID_KEYSTORE_PASSWORD: ${{ secrets.ANDROID_KEYSTORE_PASSWORD }} + ANDROID_KEY_ALIAS: ${{ secrets.ANDROID_KEY_ALIAS }} + ANDROID_KEY_PASSWORD: ${{ secrets.ANDROID_KEY_PASSWORD }} + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_REGION: ${{ secrets.AWS_REGION }} diff --git a/mobile/react-native/staging-deploy-ios.yml b/mobile/react-native/staging-deploy-ios.yml new file mode 100644 index 0000000..499c98a --- /dev/null +++ b/mobile/react-native/staging-deploy-ios.yml @@ -0,0 +1,27 @@ +name: 5. Staging iOS Deployment + +run-name: > + Staging iOS deployment: Manual dispatch ${{ github.ref_name }} + +on: + workflow_dispatch: + +jobs: + staging-ios: + uses: steplix/cicd-steplix/.github/workflows/mob-react-native-staging-deploy-ios.yml@main + with: + COMMIT_MESSAGE: Manual dispatch ${{ github.ref_name }} + TAG: ${{ github.ref_name }} + PROJECT_PATH: ios/project.xcodeproj + WORKSPACE_PATH: ios/project.xcworkspace + secrets: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }} + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_REGION: ${{ secrets.AWS_REGION }} + FIREBASE_IOS_APP_ID: ${{ secrets.FIREBASE_IOS_APP_ID }} + IOS_CERTIFICATE_PASSWORD: ${{ secrets.IOS_CERTIFICATE_PASSWORD }} + IOS_MOBILE_PROVISION_BASE64: ${{ secrets.IOS_MOBILE_PROVISION_BASE64 }} + IOS_P12_BASE64: ${{ secrets.IOS_P12_BASE64 }} + IOS_TEAM_ID: ${{ secrets.IOS_TEAM_ID }} \ No newline at end of file diff --git a/mobile/react-native/testing-deploy-android.yml b/mobile/react-native/testing-deploy-android.yml new file mode 100644 index 0000000..1e35d27 --- /dev/null +++ b/mobile/react-native/testing-deploy-android.yml @@ -0,0 +1,28 @@ +name: 2. Testing Android Deployment + +run-name: > + Testing Android deployment: ${{ github.event.head_commit.message }} + +on: + push: + branches: + - testing + +jobs: + testing-android: + uses: steplix/cicd-steplix/.github/workflows/mob-react-native-testing-deploy-android.yml@main + with: + COMMIT_MESSAGE: ${{ github.event.head_commit.message }} + PR_BRANCH: master + ANDROID_KEYSTORE_NAME: ${{ vars.ANDROID_KEYSTORE_NAME }} + secrets: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + FIREBASE_ANDROID_APP_ID: ${{ secrets.FIREBASE_ANDROID_APP_ID }} + FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }} + ANDROID_KEYSTORE_BASE64: ${{ secrets.ANDROID_KEYSTORE_BASE64 }} + ANDROID_KEYSTORE_PASSWORD: ${{ secrets.ANDROID_KEYSTORE_PASSWORD }} + ANDROID_KEY_ALIAS: ${{ secrets.ANDROID_KEY_ALIAS }} + ANDROID_KEY_PASSWORD: ${{ secrets.ANDROID_KEY_PASSWORD }} + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_REGION: ${{ secrets.AWS_REGION }} diff --git a/mobile/react-native/testing-deploy-ios.yml b/mobile/react-native/testing-deploy-ios.yml new file mode 100644 index 0000000..1c66e2c --- /dev/null +++ b/mobile/react-native/testing-deploy-ios.yml @@ -0,0 +1,27 @@ +name: 3. Testing iOS Deployment + +run-name: > + Testing iOS deployment: Manual dispatch ${{ github.ref_name }} + +on: + workflow_dispatch: + +jobs: + testing-ios: + uses: steplix/cicd-steplix/.github/workflows/mob-react-native-testing-deploy-ios.yml@main + with: + COMMIT_MESSAGE: Manual dispatch ${{ github.ref_name }} + PR_BRANCH: master + PROJECT_PATH: ios/project.xcodeproj + WORKSPACE_PATH: ios/project.xcworkspace + secrets: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }} + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_REGION: ${{ secrets.AWS_REGION }} + FIREBASE_IOS_APP_ID: ${{ secrets.FIREBASE_IOS_APP_ID }} + IOS_CERTIFICATE_PASSWORD: ${{ secrets.IOS_CERTIFICATE_PASSWORD }} + IOS_MOBILE_PROVISION_BASE64: ${{ secrets.IOS_MOBILE_PROVISION_BASE64 }} + IOS_P12_BASE64: ${{ secrets.IOS_P12_BASE64 }} + IOS_TEAM_ID: ${{ secrets.IOS_TEAM_ID }} From 91ce0e4291ce99528f7238f511e6a2d28c1f595d Mon Sep 17 00:00:00 2001 From: leandro Date: Fri, 10 Feb 2023 15:29:52 -0300 Subject: [PATCH 27/44] adding static web in s3 workflows templates --- .../github/web-s3-develop-push-cicd.yml | 46 +++++++++++++++ .../github/web-s3-hotfix-push-cicd.yml | 53 +++++++++++++++++ .../github/web-s3-master-push-cicd.yml | 55 +++++++++++++++++ ...web-s3-realease-production-deploy-cicd.yml | 59 +++++++++++++++++++ .../github/web-s3-testing-deploy-cicd.yml | 53 +++++++++++++++++ .github/workflows/web-s3-create-tag.yml | 42 +++++++++++++ .github/workflows/web-s3-generate-pr.yml | 38 ++++++++++++ .github/workflows/web-s3-validate.yml | 26 ++++++++ 8 files changed, 372 insertions(+) create mode 100644 .github/web/static-s3/github/web-s3-develop-push-cicd.yml create mode 100644 .github/web/static-s3/github/web-s3-hotfix-push-cicd.yml create mode 100644 .github/web/static-s3/github/web-s3-master-push-cicd.yml create mode 100644 .github/web/static-s3/github/web-s3-realease-production-deploy-cicd.yml create mode 100644 .github/web/static-s3/github/web-s3-testing-deploy-cicd.yml create mode 100644 .github/workflows/web-s3-create-tag.yml create mode 100644 .github/workflows/web-s3-generate-pr.yml create mode 100644 .github/workflows/web-s3-validate.yml diff --git a/.github/web/static-s3/github/web-s3-develop-push-cicd.yml b/.github/web/static-s3/github/web-s3-develop-push-cicd.yml new file mode 100644 index 0000000..3f786a7 --- /dev/null +++ b/.github/web/static-s3/github/web-s3-develop-push-cicd.yml @@ -0,0 +1,46 @@ +name: Push in development branch +run-name: > + "Create PR FROM develop TO ${{ vars.DESTINATION_PR_ON_DEVELOP_WORKFLOW }}: ${{ github.event.head_commit.message }}" + +on: + push: + branches: + - develop + + +jobs: + testing: + uses: ./.github/workflows/web-s3-validate.yml + with: + node-version: ${{ vars.NODE_VERSION }} + + build: + needs: [ testing ] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: ${{ vars.NODE_VERSION }} + - run: npm ci + - run: npm run release + + + generate-pr: + needs: [build] + uses: ./.github/workflows/web-s3-generate-pr.yml + with: + destination-branch-name: ${{ vars.DESTINATION_PR_ON_DEVELOP_WORKFLOW }} + pr-title: "Pushing develop into ${{ vars.DESTINATION_PR_ON_DEVELOP_WORKFLOW }}" + + notify: + if: ${{ always() }} + needs: [testing, build, generate-pr] + runs-on: ubuntu-latest + steps: + - name: Notify Slack + uses: steplix/cicd-notify@0.0.17 + with: + template: 'push' + status: ${{ needs.testing.result || needs.build.result || needs.generate-pr.result }} + slack_webhook_url: ${{ secrets.SLACK_WEBHOOK }} \ No newline at end of file diff --git a/.github/web/static-s3/github/web-s3-hotfix-push-cicd.yml b/.github/web/static-s3/github/web-s3-hotfix-push-cicd.yml new file mode 100644 index 0000000..5ec674e --- /dev/null +++ b/.github/web/static-s3/github/web-s3-hotfix-push-cicd.yml @@ -0,0 +1,53 @@ +name: Push Hotfix in master branch +run-name: > + Push: ${{ github.ref_name }} + +on: + push: + branches: + - 'hotfix/**' + + +jobs: + + testing: + uses: ./.github/workflows/web-s3-validate.yml + with: + node-version: ${{ vars.NODE_VERSION }} + + build: + needs: [ testing ] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: ${{ vars.NODE_VERSION }} + - run: npm ci + - run: npm run release + + generate-pr-to-master: + needs: [testing,build] + uses: ./.github/workflows/web-s3-generate-pr.yml + with: + destination-branch-name: ${{ vars.DESTINATION_PR_ON_TESTING_WORKFLOW }} + pr-title: " is TAG VERSION INCREMENT: Pushing HOTFIX ${{ github.ref_name }} into Master" + + generate-pr-to-develop: + needs: [testing,build] + uses: ./.github/workflows/web-s3-generate-pr.yml + with: + destination-branch-name: ${{ vars.DESTINATION_PR_ON_DEVELOP_WORKFLOW }} + pr-title: "Pushing HOTFIX ${{ github.ref_name }} into Develop" + + notify: + if: ${{ always() }} + needs: [ testing,build,generate-pr-to-master,generate-pr-to-develop ] + runs-on: ubuntu-latest + steps: + - name: Notify Slack + uses: steplix/cicd-notify@0.0.17 + with: + template: 'push' + status: ${{ needs.testing.result || needs.build.result || needs.generate-pr-to-master.result || needs.generate-pr-to-develop.result }} + slack_webhook_url: ${{ secrets.SLACK_WEBHOOK }} \ No newline at end of file diff --git a/.github/web/static-s3/github/web-s3-master-push-cicd.yml b/.github/web/static-s3/github/web-s3-master-push-cicd.yml new file mode 100644 index 0000000..eb1b012 --- /dev/null +++ b/.github/web/static-s3/github/web-s3-master-push-cicd.yml @@ -0,0 +1,55 @@ +name: Push in master branch +run-name: > + ${{ github.event.pull_request.title }} + +on: + push: + branches: + - master + + +jobs: + + tagging: + if: github.event.pull_request.merged == true + uses: ./.github/workflows/web-s3-create-tag.yml + with: + text-where-search-for-parameters: ${{ github.event.pull_request.title }} + + build-zip-upload: + needs: [ tagging ] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: ${{ vars.NODE_VERSION }} + - run: npm ci + - run: npm run release + #ZIP + - name: generate-zip + id: zip + run: cd out && tar -czvf ${{ needs.tagging.outputs.tag }}.tar.gz * + + #UPLOAD + - uses: aws-actions/configure-aws-credentials@v1.7.0 + with: + aws-access-key-id: ${{ secrets.PROD_AWS_KEY_ID }} + aws-secret-access-key: ${{ secrets.PROD_AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ secrets.PROD_AWS_REGION }} + - name: copy files to S3 + run: | + aws s3 cp out/${{ needs.tagging.outputs.tag }}.tar.gz s3://${{ vars.PROD_AWS_BUCKET_ARTIFACT }}/${{ needs.tagging.outputs.tag }}.tar.gz + + + notify: + if: ${{ always() }} + needs: [ tagging,build-zip-upload ] + runs-on: ubuntu-latest + steps: + - name: Notify Slack + uses: steplix/cicd-notify@0.0.17 + with: + template: 'push' + status: ${{ needs.tagging.result || needs.build-zip-upload.result }} + slack_webhook_url: ${{ secrets.SLACK_WEBHOOK }} \ No newline at end of file diff --git a/.github/web/static-s3/github/web-s3-realease-production-deploy-cicd.yml b/.github/web/static-s3/github/web-s3-realease-production-deploy-cicd.yml new file mode 100644 index 0000000..60f0e8b --- /dev/null +++ b/.github/web/static-s3/github/web-s3-realease-production-deploy-cicd.yml @@ -0,0 +1,59 @@ +name: Deployment to production +run-name: > + Production deployment ${{ github.event.release.tag_name }}: ${{ github.event.release.name }} +on: + release: + types: [published] + + +jobs: + + ## DEPLOY + + download_unzip_deploy: + runs-on: ubuntu-latest + steps: + #DOWNLOAD + - uses: aws-actions/configure-aws-credentials@v1.7.0 + with: + aws-access-key-id: ${{ secrets.PROD_AWS_KEY_ID }} + aws-secret-access-key: ${{ secrets.PROD_AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ secrets.PROD_AWS_REGION }} + + - name: download zip from S3 + run: | + aws s3 cp s3://${{ vars.PROD_AWS_BUCKET_ARTIFACT }}/${{ github.event.release.tag_name }}.tar.gz . + #UNZIP + - name: mkdir + run: mkdir output + + - name: un-zip + id: unzip + run: tar -xvzf ${{ github.event.release.tag_name }}.tar.gz -C output + + #UPLOAD + - uses: aws-actions/configure-aws-credentials@v1.7.0 + with: + aws-access-key-id: ${{ secrets.PROD_AWS_KEY_ID }} + aws-secret-access-key: ${{ secrets.PROD_AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ secrets.PROD_AWS_REGION }} + - name: copy files to S3 + run: | + aws s3 sync output s3://${{ vars.PROD_AWS_BUCKET }} + - name: Cloudfront invalidation + run: | + aws cloudfront create-invalidation --distribution-id ${{ vars.PROD_AWS_CLOUDFRONT_DISTRIBUTION_ID }} --paths "/*" + + + + notify: + if: ${{ always() }} + needs: [ download_unzip_deploy ] + runs-on: ubuntu-latest + steps: + - name: Notify Slack + uses: steplix/cicd-notify@0.0.17 + with: + template: 'push' + status: ${{ needs.download_unzip_deploy.result}} + slack_webhook_url: ${{ secrets.SLACK_WEBHOOK }} \ No newline at end of file diff --git a/.github/web/static-s3/github/web-s3-testing-deploy-cicd.yml b/.github/web/static-s3/github/web-s3-testing-deploy-cicd.yml new file mode 100644 index 0000000..012e51c --- /dev/null +++ b/.github/web/static-s3/github/web-s3-testing-deploy-cicd.yml @@ -0,0 +1,53 @@ +name: Push in testing branch +run-name: > + "Deploying testing and creating PR to ${{ vars.DESTINATION_PR_ON_TESTING_WORKFLOW }}" +on: + push: + branches: + - testing + + +jobs: + + build_deploy: + runs-on: ubuntu-latest + steps: + #BUILD + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: ${{ vars.NODE_VERSION }} + - run: npm ci + - run: npm run release + #UPLOAD + - uses: aws-actions/configure-aws-credentials@v1.7.0 + with: + aws-access-key-id: ${{ secrets.TEST_AWS_KEY_ID }} + aws-secret-access-key: ${{ secrets.TEST_AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ secrets.TEST_AWS_REGION }} + - name: copy files to S3 + run: | + aws s3 sync out s3://${{ vars.TEST_AWS_BUCKET }} + - name: Cloudfront invalidation + run: | + aws cloudfront create-invalidation --distribution-id ${{ vars.TEST_AWS_CLOUDFRONT_DISTRIBUTION_ID }} --paths "/*" + + + generate-pr: + needs: build_deploy + uses: ./.github/workflows/web-s3-generate-pr.yml + with: + destination-branch-name: ${{ vars.DESTINATION_PR_ON_TESTING_WORKFLOW }} + pr-title: " is TAG VERSION INCREMENT: PUSHING testing INTO ${{ vars.DESTINATION_PR_ON_TESTING_WORKFLOW }}" + + notify: + if: ${{ always() }} + needs: [ build_deploy,generate-pr ] + runs-on: ubuntu-latest + steps: + - name: Notify Slack + uses: steplix/cicd-notify@0.0.17 + with: + template: 'push' + status: ${{ needs.build_deploy.result || needs.generate-pr.result }} + slack_webhook_url: ${{ secrets.SLACK_WEBHOOK }} \ No newline at end of file diff --git a/.github/workflows/web-s3-create-tag.yml b/.github/workflows/web-s3-create-tag.yml new file mode 100644 index 0000000..71abdd4 --- /dev/null +++ b/.github/workflows/web-s3-create-tag.yml @@ -0,0 +1,42 @@ +name: Create TAG + +on: + workflow_call: + inputs: + text-where-search-for-parameters: + type: string + description: 'Message to parse. Defaults to head commit message' + required: false + default: ${{ github.event.head_commit.message }} + outputs: + tag: + description: "The tag created" + value: ${{ jobs.tagging.outputs.tag }} + +jobs: + + ### Running the TAG creation + + tagging: + runs-on: ubuntu-latest + outputs: + tag: ${{ steps.bumped_tag.outputs.version }} + steps: + - uses: steplix/cicd-check-parameter@1.0.0 + id: args + with: + message: ${{ inputs.text-where-search-for-parameters}} + param-0: major + param-1: minor + + - name: Get bumping mode + id: bump-mode + run: echo "mode=${{ (steps.args.outputs.param-0 == 'true' && 'major') || (steps.args.outputs.param-1 == 'true' && 'minor') || 'patch' }}" >> $GITHUB_OUTPUT + + # Bump tag without affecting repository + - uses: zwaldowski/semver-release-action@v3 + name: Get bumped tag + id: bumped_tag + with: + bump: ${{ steps.bump-mode.outputs.mode }} + github_token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/web-s3-generate-pr.yml b/.github/workflows/web-s3-generate-pr.yml new file mode 100644 index 0000000..c47f671 --- /dev/null +++ b/.github/workflows/web-s3-generate-pr.yml @@ -0,0 +1,38 @@ +name: generate pr + +on: + workflow_call: + inputs: + origin-branch-name: + type: string + description: "Name of the branch of origin from which the pr starts. If blank, default: triggered branch" + default: "" + required: false + destination-branch-name: + type: string + description: "Destination branch name for the pr" + required: true + pr-title: + type: string + description: "Title for the pr" + default: "An automated PR" + required: false + + + +jobs: + + ### Generating PR + + generate-pr: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: generate-pr + id: open-pr + uses: repo-sync/pull-request@v2 + with: + source_branch: ${{ inputs.origin-branch-name }} + destination_branch: ${{ inputs.destination-branch-name }} + pr_title: ${{ inputs.pr-title }} + - run: echo "PR GENERATED SUCCESSFULLY" \ No newline at end of file diff --git a/.github/workflows/web-s3-validate.yml b/.github/workflows/web-s3-validate.yml new file mode 100644 index 0000000..ea53a4a --- /dev/null +++ b/.github/workflows/web-s3-validate.yml @@ -0,0 +1,26 @@ +name: Test + +on: + workflow_call: + inputs: + node-version: + description: 'Node version to use' + type: string + default: 14.18.0 + required: false + +jobs: + + ### Running the Test + + verify: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: ${{ inputs.node-version }} + - run: npm ci + - run: npm run lint --if-present + - run: npm run test --if-present + - run: echo "TEST SUCCESSFULLY" From 21313d0523ae108c288611d1efd1a187bbd28b47 Mon Sep 17 00:00:00 2001 From: leandro Date: Fri, 10 Feb 2023 16:10:06 -0300 Subject: [PATCH 28/44] change reference to reposiory --- .github/web/static-s3/github/web-s3-develop-push-cicd.yml | 4 ++-- .github/web/static-s3/github/web-s3-hotfix-push-cicd.yml | 6 +++--- .github/web/static-s3/github/web-s3-master-push-cicd.yml | 2 +- .github/web/static-s3/github/web-s3-testing-deploy-cicd.yml | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/web/static-s3/github/web-s3-develop-push-cicd.yml b/.github/web/static-s3/github/web-s3-develop-push-cicd.yml index 3f786a7..7e6aa74 100644 --- a/.github/web/static-s3/github/web-s3-develop-push-cicd.yml +++ b/.github/web/static-s3/github/web-s3-develop-push-cicd.yml @@ -10,7 +10,7 @@ on: jobs: testing: - uses: ./.github/workflows/web-s3-validate.yml + uses: steplix/cicd-steplix/.github/workflows/web-s3-validate.yml@main with: node-version: ${{ vars.NODE_VERSION }} @@ -28,7 +28,7 @@ jobs: generate-pr: needs: [build] - uses: ./.github/workflows/web-s3-generate-pr.yml + uses: steplix/cicd-steplix/.github/workflows/web-s3-generate-pr.yml@main with: destination-branch-name: ${{ vars.DESTINATION_PR_ON_DEVELOP_WORKFLOW }} pr-title: "Pushing develop into ${{ vars.DESTINATION_PR_ON_DEVELOP_WORKFLOW }}" diff --git a/.github/web/static-s3/github/web-s3-hotfix-push-cicd.yml b/.github/web/static-s3/github/web-s3-hotfix-push-cicd.yml index 5ec674e..2a8d117 100644 --- a/.github/web/static-s3/github/web-s3-hotfix-push-cicd.yml +++ b/.github/web/static-s3/github/web-s3-hotfix-push-cicd.yml @@ -11,7 +11,7 @@ on: jobs: testing: - uses: ./.github/workflows/web-s3-validate.yml + uses: steplix/cicd-steplix/.github/workflows/web-s3-validate.yml@main with: node-version: ${{ vars.NODE_VERSION }} @@ -28,14 +28,14 @@ jobs: generate-pr-to-master: needs: [testing,build] - uses: ./.github/workflows/web-s3-generate-pr.yml + uses: steplix/cicd-steplix/.github/workflows/web-s3-generate-pr.yml@main with: destination-branch-name: ${{ vars.DESTINATION_PR_ON_TESTING_WORKFLOW }} pr-title: " is TAG VERSION INCREMENT: Pushing HOTFIX ${{ github.ref_name }} into Master" generate-pr-to-develop: needs: [testing,build] - uses: ./.github/workflows/web-s3-generate-pr.yml + uses: steplix/cicd-steplix/.github/workflows/web-s3-generate-pr.yml@main with: destination-branch-name: ${{ vars.DESTINATION_PR_ON_DEVELOP_WORKFLOW }} pr-title: "Pushing HOTFIX ${{ github.ref_name }} into Develop" diff --git a/.github/web/static-s3/github/web-s3-master-push-cicd.yml b/.github/web/static-s3/github/web-s3-master-push-cicd.yml index eb1b012..d25acbc 100644 --- a/.github/web/static-s3/github/web-s3-master-push-cicd.yml +++ b/.github/web/static-s3/github/web-s3-master-push-cicd.yml @@ -12,7 +12,7 @@ jobs: tagging: if: github.event.pull_request.merged == true - uses: ./.github/workflows/web-s3-create-tag.yml + uses: steplix/cicd-steplix/.github/workflows/web-s3-create-tag.yml@main with: text-where-search-for-parameters: ${{ github.event.pull_request.title }} diff --git a/.github/web/static-s3/github/web-s3-testing-deploy-cicd.yml b/.github/web/static-s3/github/web-s3-testing-deploy-cicd.yml index 012e51c..63d9268 100644 --- a/.github/web/static-s3/github/web-s3-testing-deploy-cicd.yml +++ b/.github/web/static-s3/github/web-s3-testing-deploy-cicd.yml @@ -35,7 +35,7 @@ jobs: generate-pr: needs: build_deploy - uses: ./.github/workflows/web-s3-generate-pr.yml + uses: steplix/cicd-steplix/.github/workflows/web-s3-generate-pr.yml@main with: destination-branch-name: ${{ vars.DESTINATION_PR_ON_TESTING_WORKFLOW }} pr-title: " is TAG VERSION INCREMENT: PUSHING testing INTO ${{ vars.DESTINATION_PR_ON_TESTING_WORKFLOW }}" From 3fee2ec50e07e000167772ec3f1c0858c84c4ca0 Mon Sep 17 00:00:00 2001 From: leandro Date: Wed, 15 Feb 2023 17:55:42 -0300 Subject: [PATCH 29/44] refactor pipes --- .github/workflows/web-s3-create-tag.yml | 42 ------------------- .github/workflows/web-s3-develop-push.yml | 0 .github/workflows/web-s3-generate-pr.yml | 38 ----------------- .github/workflows/web-s3-hotfix-push.yml | 0 .github/workflows/web-s3-master-push.yml | 0 .github/workflows/web-s3-release-deploy.yml | 0 .github/workflows/web-s3-testing-deploy.yml | 0 .github/workflows/web-s3-validate.yml | 26 ------------ .../github/web-s3-develop-push-cicd.yml | 0 .../github/web-s3-hotfix-push-cicd.yml | 0 .../github/web-s3-master-push-cicd.yml | 0 ...web-s3-realease-production-deploy-cicd.yml | 0 .../github/web-s3-testing-deploy-cicd.yml | 0 13 files changed, 106 deletions(-) delete mode 100644 .github/workflows/web-s3-create-tag.yml create mode 100644 .github/workflows/web-s3-develop-push.yml delete mode 100644 .github/workflows/web-s3-generate-pr.yml create mode 100644 .github/workflows/web-s3-hotfix-push.yml create mode 100644 .github/workflows/web-s3-master-push.yml create mode 100644 .github/workflows/web-s3-release-deploy.yml create mode 100644 .github/workflows/web-s3-testing-deploy.yml delete mode 100644 .github/workflows/web-s3-validate.yml rename {.github/web => web}/static-s3/github/web-s3-develop-push-cicd.yml (100%) rename {.github/web => web}/static-s3/github/web-s3-hotfix-push-cicd.yml (100%) rename {.github/web => web}/static-s3/github/web-s3-master-push-cicd.yml (100%) rename {.github/web => web}/static-s3/github/web-s3-realease-production-deploy-cicd.yml (100%) rename {.github/web => web}/static-s3/github/web-s3-testing-deploy-cicd.yml (100%) diff --git a/.github/workflows/web-s3-create-tag.yml b/.github/workflows/web-s3-create-tag.yml deleted file mode 100644 index 71abdd4..0000000 --- a/.github/workflows/web-s3-create-tag.yml +++ /dev/null @@ -1,42 +0,0 @@ -name: Create TAG - -on: - workflow_call: - inputs: - text-where-search-for-parameters: - type: string - description: 'Message to parse. Defaults to head commit message' - required: false - default: ${{ github.event.head_commit.message }} - outputs: - tag: - description: "The tag created" - value: ${{ jobs.tagging.outputs.tag }} - -jobs: - - ### Running the TAG creation - - tagging: - runs-on: ubuntu-latest - outputs: - tag: ${{ steps.bumped_tag.outputs.version }} - steps: - - uses: steplix/cicd-check-parameter@1.0.0 - id: args - with: - message: ${{ inputs.text-where-search-for-parameters}} - param-0: major - param-1: minor - - - name: Get bumping mode - id: bump-mode - run: echo "mode=${{ (steps.args.outputs.param-0 == 'true' && 'major') || (steps.args.outputs.param-1 == 'true' && 'minor') || 'patch' }}" >> $GITHUB_OUTPUT - - # Bump tag without affecting repository - - uses: zwaldowski/semver-release-action@v3 - name: Get bumped tag - id: bumped_tag - with: - bump: ${{ steps.bump-mode.outputs.mode }} - github_token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/web-s3-develop-push.yml b/.github/workflows/web-s3-develop-push.yml new file mode 100644 index 0000000..e69de29 diff --git a/.github/workflows/web-s3-generate-pr.yml b/.github/workflows/web-s3-generate-pr.yml deleted file mode 100644 index c47f671..0000000 --- a/.github/workflows/web-s3-generate-pr.yml +++ /dev/null @@ -1,38 +0,0 @@ -name: generate pr - -on: - workflow_call: - inputs: - origin-branch-name: - type: string - description: "Name of the branch of origin from which the pr starts. If blank, default: triggered branch" - default: "" - required: false - destination-branch-name: - type: string - description: "Destination branch name for the pr" - required: true - pr-title: - type: string - description: "Title for the pr" - default: "An automated PR" - required: false - - - -jobs: - - ### Generating PR - - generate-pr: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: generate-pr - id: open-pr - uses: repo-sync/pull-request@v2 - with: - source_branch: ${{ inputs.origin-branch-name }} - destination_branch: ${{ inputs.destination-branch-name }} - pr_title: ${{ inputs.pr-title }} - - run: echo "PR GENERATED SUCCESSFULLY" \ No newline at end of file diff --git a/.github/workflows/web-s3-hotfix-push.yml b/.github/workflows/web-s3-hotfix-push.yml new file mode 100644 index 0000000..e69de29 diff --git a/.github/workflows/web-s3-master-push.yml b/.github/workflows/web-s3-master-push.yml new file mode 100644 index 0000000..e69de29 diff --git a/.github/workflows/web-s3-release-deploy.yml b/.github/workflows/web-s3-release-deploy.yml new file mode 100644 index 0000000..e69de29 diff --git a/.github/workflows/web-s3-testing-deploy.yml b/.github/workflows/web-s3-testing-deploy.yml new file mode 100644 index 0000000..e69de29 diff --git a/.github/workflows/web-s3-validate.yml b/.github/workflows/web-s3-validate.yml deleted file mode 100644 index ea53a4a..0000000 --- a/.github/workflows/web-s3-validate.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: Test - -on: - workflow_call: - inputs: - node-version: - description: 'Node version to use' - type: string - default: 14.18.0 - required: false - -jobs: - - ### Running the Test - - verify: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - node-version: ${{ inputs.node-version }} - - run: npm ci - - run: npm run lint --if-present - - run: npm run test --if-present - - run: echo "TEST SUCCESSFULLY" diff --git a/.github/web/static-s3/github/web-s3-develop-push-cicd.yml b/web/static-s3/github/web-s3-develop-push-cicd.yml similarity index 100% rename from .github/web/static-s3/github/web-s3-develop-push-cicd.yml rename to web/static-s3/github/web-s3-develop-push-cicd.yml diff --git a/.github/web/static-s3/github/web-s3-hotfix-push-cicd.yml b/web/static-s3/github/web-s3-hotfix-push-cicd.yml similarity index 100% rename from .github/web/static-s3/github/web-s3-hotfix-push-cicd.yml rename to web/static-s3/github/web-s3-hotfix-push-cicd.yml diff --git a/.github/web/static-s3/github/web-s3-master-push-cicd.yml b/web/static-s3/github/web-s3-master-push-cicd.yml similarity index 100% rename from .github/web/static-s3/github/web-s3-master-push-cicd.yml rename to web/static-s3/github/web-s3-master-push-cicd.yml diff --git a/.github/web/static-s3/github/web-s3-realease-production-deploy-cicd.yml b/web/static-s3/github/web-s3-realease-production-deploy-cicd.yml similarity index 100% rename from .github/web/static-s3/github/web-s3-realease-production-deploy-cicd.yml rename to web/static-s3/github/web-s3-realease-production-deploy-cicd.yml diff --git a/.github/web/static-s3/github/web-s3-testing-deploy-cicd.yml b/web/static-s3/github/web-s3-testing-deploy-cicd.yml similarity index 100% rename from .github/web/static-s3/github/web-s3-testing-deploy-cicd.yml rename to web/static-s3/github/web-s3-testing-deploy-cicd.yml From ee756f9167ce16b6e48d8a6853d39529b31710e0 Mon Sep 17 00:00:00 2001 From: leandro Date: Wed, 15 Feb 2023 17:56:14 -0300 Subject: [PATCH 30/44] refactor finish --- .github/workflows/web-s3-develop-push.yml | 81 +++++++++++++++ .github/workflows/web-s3-hotfix-push.yml | 85 ++++++++++++++++ .github/workflows/web-s3-master-push.yml | 99 +++++++++++++++++++ .github/workflows/web-s3-release-deploy.yml | 83 ++++++++++++++++ .github/workflows/web-s3-testing-deploy.yml | 93 +++++++++++++++++ .../github/web-s3-develop-push-cicd.yml | 46 +++------ .../github/web-s3-hotfix-push-cicd.yml | 53 +++------- .../github/web-s3-master-push-cicd.yml | 57 +++-------- ...web-s3-realease-production-deploy-cicd.yml | 67 ++++--------- .../github/web-s3-testing-deploy-cicd.yml | 59 ++++------- 10 files changed, 518 insertions(+), 205 deletions(-) diff --git a/.github/workflows/web-s3-develop-push.yml b/.github/workflows/web-s3-develop-push.yml index e69de29..37557e3 100644 --- a/.github/workflows/web-s3-develop-push.yml +++ b/.github/workflows/web-s3-develop-push.yml @@ -0,0 +1,81 @@ +name: Push in development branch +run-name: > + "Create PR FROM develop TO ${{ inputs.DESTINATION_PR_ON_DEVELOP_WORKFLOW }}: ${{ github.event.head_commit.message }}" + +on: + workflow_call: + inputs: + NODE_VERSION: + description: 'Node version to use' + type: string + default: 14.18.0 + required: false + DESTINATION_PR: + description: 'Branch to target MR' + type: string + default: testing + required: false + PR_TITLE: + type: string + description: "Title for the pr" + default: "Pushing develop" + required: false + SLACK_CHANNEL: + type: string + description: Slack channel to send notifications + required: false + secrets: + SLACK_WEBHOOK_URL: + required: true + +jobs: + + testing: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: ${{ inputs.NODE_VERSION }} + - run: npm ci + - run: npm run lint --if-present + - run: npm run test --if-present + - run: echo "TEST SUCCESSFULLY" + + build: + needs: [ testing ] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: ${{ inputs.NODE_VERSION }} + - run: npm ci + - run: npm run release + + + generate-pr: + needs: [ build ] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: generate-pr + id: open-pr + uses: repo-sync/pull-request@v2 + with: + destination_branch: ${{ inputs.DESTINATION_PR }} + pr_title: ${{ inputs.PR_TITLE }} + - run: echo "PR GENERATED SUCCESSFULLY" + + notify: + if: ${{ always() }} + needs: [testing, build, generate-pr] + runs-on: ubuntu-latest + steps: + - name: Notify Slack + uses: steplix/cicd-notify@1.0.0 + with: + template: 'push' + status: ${{ needs.testing.result || needs.build.result || needs.generate-pr.result }} + slack_webhook_url: ${{ secrets.SLACK_WEBHOOK_URL }} + channel: ${{ inputs.SLACK_CHANNEL }} \ No newline at end of file diff --git a/.github/workflows/web-s3-hotfix-push.yml b/.github/workflows/web-s3-hotfix-push.yml index e69de29..bb472c4 100644 --- a/.github/workflows/web-s3-hotfix-push.yml +++ b/.github/workflows/web-s3-hotfix-push.yml @@ -0,0 +1,85 @@ +name: Push Hotfix in master branch +run-name: > + Push: ${{ github.ref_name }} + +on: + workflow_call: + inputs: + NODE_VERSION: + description: 'Node version to use' + type: string + default: 14.18.0 + required: false + DESTINATION_PR_MASTER: + description: 'Branch to target MR' + type: string + default: master + required: false + DESTINATION_PR_DEVELOP: + description: 'Branch to target MR' + type: string + default: develop + required: false + SLACK_CHANNEL: + type: string + description: Slack channel to send notifications + required: false + secrets: + SLACK_WEBHOOK_URL: + required: true + +jobs: + + testing: + uses: steplix/cicd-steplix/.github/workflows/web-s3-validate.yml@main + with: + node-version: ${{ inputs.NODE_VERSION }} + + build: + needs: [ testing ] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: ${{ inputs.NODE_VERSION }} + - run: npm ci + - run: npm run release + + generate-pr-to-master: + needs: [testing,build] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: generate-pr + id: open-pr + uses: repo-sync/pull-request@v2 + with: + destination_branch: ${{ inputs.DESTINATION_PR_MASTER }} + pr_title: " is TAG VERSION INCREMENT: Pushing HOTFIX ${{ github.ref_name }} into ${{ inputs.DESTINATION_PR_MASTER }}" + - run: echo "PR GENERATED SUCCESSFULLY" + + generate-pr-to-develop: + needs: [testing,build] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: generate-pr + id: open-pr + uses: repo-sync/pull-request@v2 + with: + destination_branch: ${{ inputs.DESTINATION_PR_DEVELOP }} + pr-title: "Pushing HOTFIX ${{ github.ref_name }} into ${{ inputs.DESTINATION_PR_DEVELOP }}" + + notify: + if: ${{ always() }} + needs: [ testing,build,generate-pr-to-master,generate-pr-to-develop ] + runs-on: ubuntu-latest + steps: + - name: Notify Slack + uses: steplix/cicd-notify@1.0.0 + with: + template: 'push' + status: ${{ needs.testing.result || needs.build.result || needs.generate-pr-to-master.result || needs.generate-pr-to-develop.result }} + slack_webhook_url: ${{ secrets.SLACK_WEBHOOK }} + channel: ${{ inputs.SLACK_CHANNEL }} \ No newline at end of file diff --git a/.github/workflows/web-s3-master-push.yml b/.github/workflows/web-s3-master-push.yml index e69de29..f4ec00d 100644 --- a/.github/workflows/web-s3-master-push.yml +++ b/.github/workflows/web-s3-master-push.yml @@ -0,0 +1,99 @@ +name: Push in master branch +run-name: > + ${{ github.event.pull_request.title }} + +on: + workflow_call: + inputs: + NODE_VERSION: + description: 'Node version to use' + type: string + default: 14.18.0 + required: false + SLACK_CHANNEL: + type: string + description: Slack channel to send notifications + required: false + AWS_BUCKET: + type: string + description: Bucket S3 to copy files for deploy + required: true + TEXT-WHERE-SEARCH-FOR-PARAMETERS: + type: string + description: 'Message to parse. Defaults to head commit message' + required: false + default: ${{ github.event.head_commit.message }} + secrets: + SLACK_WEBHOOK_URL: + required: true + AWS_KEY_ID: + required: true + AWS_SECRET_ACCESS_KEY: + required: true + AWS_REGION: + required: true + + +jobs: + + tagging: + runs-on: ubuntu-latest + outputs: + tag: ${{ steps.bumped_tag.outputs.version }} + steps: + - uses: steplix/cicd-check-parameter@1.0.0 + id: args + with: + message: ${{ inputs.TEXT-WHERE-SEARCH-FOR-PARAMETERS}} + param-0: major + param-1: minor + + - name: Get bumping mode + id: bump-mode + run: echo "mode=${{ (steps.args.outputs.param-0 == 'true' && 'major') || (steps.args.outputs.param-1 == 'true' && 'minor') || 'patch' }}" >> $GITHUB_OUTPUT + + # Bump tag without affecting repository + - uses: zwaldowski/semver-release-action@v3 + name: Get bumped tag + id: bumped_tag + with: + bump: ${{ steps.bump-mode.outputs.mode }} + github_token: ${{ secrets.GITHUB_TOKEN }} + + build-zip-upload: + needs: [ tagging ] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: ${{ inputs.NODE_VERSION }} + - run: npm ci + - run: npm run release + #ZIP + - name: generate-zip + id: zip + run: cd out && tar -czvf ${{ needs.tagging.outputs.tag }}.tar.gz * + + #UPLOAD + - uses: aws-actions/configure-aws-credentials@v1.7.0 + with: + aws-access-key-id: ${{ secrets.AWS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ secrets.AWS_REGION }} + - name: copy files to S3 + run: | + aws s3 cp out/${{ needs.tagging.outputs.tag }}.tar.gz s3://${{ inputs.AWS_BUCKET }}/${{ needs.tagging.outputs.tag }}.tar.gz + + + notify: + if: ${{ always() }} + needs: [ tagging,build-zip-upload ] + runs-on: ubuntu-latest + steps: + - name: Notify Slack + uses: steplix/cicd-notify@0.0.17 + with: + template: 'push' + status: ${{ needs.tagging.result || needs.build-zip-upload.result }} + slack_webhook_url: ${{ secrets.SLACK_WEBHOOK }} \ No newline at end of file diff --git a/.github/workflows/web-s3-release-deploy.yml b/.github/workflows/web-s3-release-deploy.yml index e69de29..f305220 100644 --- a/.github/workflows/web-s3-release-deploy.yml +++ b/.github/workflows/web-s3-release-deploy.yml @@ -0,0 +1,83 @@ +name: Deployment to production +run-name: > + Production deployment ${{ github.event.release.tag_name }}: ${{ github.event.release.name }} + +on: + workflow_call: + inputs: + SLACK_CHANNEL: + type: string + description: Slack channel to send notifications + required: false + AWS_BUCKET: + type: string + description: Bucket S3 to copy files for deploy + required: true + AWS_BUCKET_ARTIFACT: + type: string + description: Bucket S3 to download artifact to deploy + required: true + secrets: + SLACK_WEBHOOK_URL: + required: true + AWS_KEY_ID: + required: true + AWS_SECRET_ACCESS_KEY: + required: true + AWS_REGION: + required: true + AWS_CLOUDFRONT_DISTRIBUTION_ID: + required: true + +jobs: + + ## DEPLOY + + download_unzip_deploy: + runs-on: ubuntu-latest + steps: + #DOWNLOAD + - uses: aws-actions/configure-aws-credentials@v1.7.0 + with: + aws-access-key-id: ${{ secrets.AWS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ secrets.AWS_REGION }} + + - name: download zip from S3 + run: | + aws s3 cp s3://${{ inputs.AWS_BUCKET_ARTIFACT }}/${{ github.event.release.tag_name }}.tar.gz . + #UNZIP + - name: mkdir + run: mkdir output + + - name: un-zip + id: unzip + run: tar -xvzf ${{ github.event.release.tag_name }}.tar.gz -C output + + #UPLOAD + - uses: aws-actions/configure-aws-credentials@v1.7.0 + with: + aws-access-key-id: ${{ secrets.PROD_AWS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ secrets.PROD_AWS_REGION }} + - name: copy files to S3 + run: | + aws s3 sync output s3://${{ inputs.AWS_BUCKET }} + - name: Cloudfront invalidation + run: | + aws cloudfront create-invalidation --distribution-id ${{ inputs.AWS_CLOUDFRONT_DISTRIBUTION_ID }} --paths "/*" + + + + notify: + if: ${{ always() }} + needs: [ download_unzip_deploy ] + runs-on: ubuntu-latest + steps: + - name: Notify Slack + uses: steplix/cicd-notify@1.0.0 + with: + template: 'push' + status: ${{ needs.download_unzip_deploy.result}} + slack_webhook_url: ${{ secrets.SLACK_WEBHOOK }} + channel: ${{ inputs.SLACK_CHANNEL }} \ No newline at end of file diff --git a/.github/workflows/web-s3-testing-deploy.yml b/.github/workflows/web-s3-testing-deploy.yml index e69de29..fd267a5 100644 --- a/.github/workflows/web-s3-testing-deploy.yml +++ b/.github/workflows/web-s3-testing-deploy.yml @@ -0,0 +1,93 @@ +name: Push in testing branch +run-name: > + "Deploying testing and creating PR to ${{ vars.DESTINATION_PR_ON_TESTING_WORKFLOW }}" + +on: + workflow_call: + inputs: + NODE_VERSION: + description: 'Node version to use' + type: string + default: 14.18.0 + required: false + DESTINATION_PR: + description: 'Branch to target MR' + type: string + default: master + required: false + PR_TITLE: + type: string + description: "Title for the pr" + default: "Pushing testing" + required: false + SLACK_CHANNEL: + type: string + description: Slack channel to send notifications + required: false + AWS_BUCKET: + type: string + description: Bucket S3 to copy files for deploy + required: true + secrets: + SLACK_WEBHOOK_URL: + required: true + AWS_KEY_ID: + required: true + AWS_SECRET_ACCESS_KEY: + required: true + AWS_REGION: + required: true + AWS_CLOUDFRONT_DISTRIBUTION_ID: + required: true + +jobs: + + build_deploy: + runs-on: ubuntu-latest + steps: + #BUILD + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: ${{ inputs.NODE_VERSION }} + - run: npm ci + - run: npm run release + #UPLOAD + - uses: aws-actions/configure-aws-credentials@v1.7.0 + with: + aws-access-key-id: ${{ secrets.AWS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ secrets.AWS_REGION }} + - name: copy files to S3 + run: | + aws s3 sync out s3://${{ inputs.AWS_BUCKET }} + - name: Cloudfront invalidation + run: | + aws cloudfront create-invalidation --distribution-id ${{ inputs.AWS_CLOUDFRONT_DISTRIBUTION_ID }} --paths "/*" + + + generate-pr: + needs: [ build_deploy ] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: generate-pr + id: open-pr + uses: repo-sync/pull-request@v2 + with: + destination_branch: ${{ inputs.DESTINATION_PR }} + pr_title: ${{ inputs.PR_TITLE }} + - run: echo "PR GENERATED SUCCESSFULLY" + + notify: + if: ${{ always() }} + needs: [ build_deploy,generate-pr ] + runs-on: ubuntu-latest + steps: + - name: Notify Slack + uses: steplix/cicd-notify@1.0.0 + with: + template: 'push' + status: ${{ needs.build_deploy.result || needs.generate-pr.result }} + slack_webhook_url: ${{ secrets.SLACK_WEBHOOK }} + channel: ${{ inputs.SLACK_CHANNEL }} \ No newline at end of file diff --git a/web/static-s3/github/web-s3-develop-push-cicd.yml b/web/static-s3/github/web-s3-develop-push-cicd.yml index 7e6aa74..b92cfad 100644 --- a/web/static-s3/github/web-s3-develop-push-cicd.yml +++ b/web/static-s3/github/web-s3-develop-push-cicd.yml @@ -7,40 +7,20 @@ on: branches: - develop +env: + NODE_VERSION: ${{ vars.NODE_VERSION }} + DESTINATION_PR: ${{ vars.DESTINATION_PR_ON_DEVELOP_WORKFLOW }} + PR_TITLE: "Pushing develop into ${{ vars.DESTINATION_PR_ON_DEVELOP_WORKFLOW }}" + SLACK_CHANNEL: ${{ vars.SLACK_CHANNEL }} jobs: - testing: - uses: steplix/cicd-steplix/.github/workflows/web-s3-validate.yml@main - with: - node-version: ${{ vars.NODE_VERSION }} - - build: - needs: [ testing ] - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - node-version: ${{ vars.NODE_VERSION }} - - run: npm ci - - run: npm run release - - generate-pr: - needs: [build] - uses: steplix/cicd-steplix/.github/workflows/web-s3-generate-pr.yml@main + develop: + uses: steplix/cicd-steplix/.github/workflows/web-s3-develop-push.yml@feature/addStaticWebWorkflows with: - destination-branch-name: ${{ vars.DESTINATION_PR_ON_DEVELOP_WORKFLOW }} - pr-title: "Pushing develop into ${{ vars.DESTINATION_PR_ON_DEVELOP_WORKFLOW }}" - - notify: - if: ${{ always() }} - needs: [testing, build, generate-pr] - runs-on: ubuntu-latest - steps: - - name: Notify Slack - uses: steplix/cicd-notify@0.0.17 - with: - template: 'push' - status: ${{ needs.testing.result || needs.build.result || needs.generate-pr.result }} - slack_webhook_url: ${{ secrets.SLACK_WEBHOOK }} \ No newline at end of file + NODE_VERSION: ${{ env.NODE_VERSION }} + DESTINATION_PR: ${{ env.DESTINATION_PR }} + PR_TITLE: ${{ env.PR_TITLE }} + SLACK_CHANNEL: ${{ env.SLACK_CHANNEL }} + secrets: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} diff --git a/web/static-s3/github/web-s3-hotfix-push-cicd.yml b/web/static-s3/github/web-s3-hotfix-push-cicd.yml index 2a8d117..dadbcde 100644 --- a/web/static-s3/github/web-s3-hotfix-push-cicd.yml +++ b/web/static-s3/github/web-s3-hotfix-push-cicd.yml @@ -7,47 +7,20 @@ on: branches: - 'hotfix/**' +env: + NODE_VERSION: ${{ vars.NODE_VERSION }} + DESTINATION_PR_MASTER: ${{ vars.DESTINATION_PR_ON_TESTING_WORKFLOW }} + DESTINATION_PR_DEVELOP: develop + SLACK_CHANNEL: ${{ vars.SLACK_CHANNEL }} jobs: - testing: - uses: steplix/cicd-steplix/.github/workflows/web-s3-validate.yml@main + hotfix: + uses: steplix/cicd-steplix/.github/workflows/web-s3-develop-push.yml@feature/addStaticWebWorkflows with: - node-version: ${{ vars.NODE_VERSION }} - - build: - needs: [ testing ] - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - node-version: ${{ vars.NODE_VERSION }} - - run: npm ci - - run: npm run release - - generate-pr-to-master: - needs: [testing,build] - uses: steplix/cicd-steplix/.github/workflows/web-s3-generate-pr.yml@main - with: - destination-branch-name: ${{ vars.DESTINATION_PR_ON_TESTING_WORKFLOW }} - pr-title: " is TAG VERSION INCREMENT: Pushing HOTFIX ${{ github.ref_name }} into Master" - - generate-pr-to-develop: - needs: [testing,build] - uses: steplix/cicd-steplix/.github/workflows/web-s3-generate-pr.yml@main - with: - destination-branch-name: ${{ vars.DESTINATION_PR_ON_DEVELOP_WORKFLOW }} - pr-title: "Pushing HOTFIX ${{ github.ref_name }} into Develop" - - notify: - if: ${{ always() }} - needs: [ testing,build,generate-pr-to-master,generate-pr-to-develop ] - runs-on: ubuntu-latest - steps: - - name: Notify Slack - uses: steplix/cicd-notify@0.0.17 - with: - template: 'push' - status: ${{ needs.testing.result || needs.build.result || needs.generate-pr-to-master.result || needs.generate-pr-to-develop.result }} - slack_webhook_url: ${{ secrets.SLACK_WEBHOOK }} \ No newline at end of file + NODE_VERSION: ${{ env.NODE_VERSION }} + DESTINATION_PR_MASTER: ${{ env.DESTINATION_PR_MASTER }} + DESTINATION_PR_DEVELOP: ${{ env.DESTINATION_PR_DEVELOP }} + SLACK_CHANNEL: ${{ env.SLACK_CHANNEL }} + secrets: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} diff --git a/web/static-s3/github/web-s3-master-push-cicd.yml b/web/static-s3/github/web-s3-master-push-cicd.yml index d25acbc..e593e7a 100644 --- a/web/static-s3/github/web-s3-master-push-cicd.yml +++ b/web/static-s3/github/web-s3-master-push-cicd.yml @@ -8,48 +8,21 @@ on: - master +env: + NODE_VERSION: ${{ vars.NODE_VERSION }} + SLACK_CHANNEL: ${{ vars.SLACK_CHANNEL }} + AWS_BUCKET: ${{ vars.PROD_AWS_BUCKET_ARTIFACT }} + jobs: - tagging: - if: github.event.pull_request.merged == true - uses: steplix/cicd-steplix/.github/workflows/web-s3-create-tag.yml@main + master: + uses: steplix/cicd-steplix/.github/workflows/web-s3-master-push.yml@feature/addStaticWebWorkflows with: - text-where-search-for-parameters: ${{ github.event.pull_request.title }} - - build-zip-upload: - needs: [ tagging ] - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - node-version: ${{ vars.NODE_VERSION }} - - run: npm ci - - run: npm run release - #ZIP - - name: generate-zip - id: zip - run: cd out && tar -czvf ${{ needs.tagging.outputs.tag }}.tar.gz * - - #UPLOAD - - uses: aws-actions/configure-aws-credentials@v1.7.0 - with: - aws-access-key-id: ${{ secrets.PROD_AWS_KEY_ID }} - aws-secret-access-key: ${{ secrets.PROD_AWS_SECRET_ACCESS_KEY }} - aws-region: ${{ secrets.PROD_AWS_REGION }} - - name: copy files to S3 - run: | - aws s3 cp out/${{ needs.tagging.outputs.tag }}.tar.gz s3://${{ vars.PROD_AWS_BUCKET_ARTIFACT }}/${{ needs.tagging.outputs.tag }}.tar.gz - - - notify: - if: ${{ always() }} - needs: [ tagging,build-zip-upload ] - runs-on: ubuntu-latest - steps: - - name: Notify Slack - uses: steplix/cicd-notify@0.0.17 - with: - template: 'push' - status: ${{ needs.tagging.result || needs.build-zip-upload.result }} - slack_webhook_url: ${{ secrets.SLACK_WEBHOOK }} \ No newline at end of file + NODE_VERSION: ${{ env.NODE_VERSION }} + SLACK_CHANNEL: ${{ env.SLACK_CHANNEL }} + AWS_BUCKET: ${{ env.AWS_BUCKET }} + secrets: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} + AWS_KEY_ID: ${{ secrets.TEST_AWS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.TEST_AWS_SECRET_ACCESS_KEY }} + AWS_REGION: ${{ secrets.TEST_AWS_REGION }} diff --git a/web/static-s3/github/web-s3-realease-production-deploy-cicd.yml b/web/static-s3/github/web-s3-realease-production-deploy-cicd.yml index 60f0e8b..56d6bd4 100644 --- a/web/static-s3/github/web-s3-realease-production-deploy-cicd.yml +++ b/web/static-s3/github/web-s3-realease-production-deploy-cicd.yml @@ -6,54 +6,23 @@ on: types: [published] -jobs: - - ## DEPLOY - - download_unzip_deploy: - runs-on: ubuntu-latest - steps: - #DOWNLOAD - - uses: aws-actions/configure-aws-credentials@v1.7.0 - with: - aws-access-key-id: ${{ secrets.PROD_AWS_KEY_ID }} - aws-secret-access-key: ${{ secrets.PROD_AWS_SECRET_ACCESS_KEY }} - aws-region: ${{ secrets.PROD_AWS_REGION }} - - - name: download zip from S3 - run: | - aws s3 cp s3://${{ vars.PROD_AWS_BUCKET_ARTIFACT }}/${{ github.event.release.tag_name }}.tar.gz . - #UNZIP - - name: mkdir - run: mkdir output - - - name: un-zip - id: unzip - run: tar -xvzf ${{ github.event.release.tag_name }}.tar.gz -C output - - #UPLOAD - - uses: aws-actions/configure-aws-credentials@v1.7.0 - with: - aws-access-key-id: ${{ secrets.PROD_AWS_KEY_ID }} - aws-secret-access-key: ${{ secrets.PROD_AWS_SECRET_ACCESS_KEY }} - aws-region: ${{ secrets.PROD_AWS_REGION }} - - name: copy files to S3 - run: | - aws s3 sync output s3://${{ vars.PROD_AWS_BUCKET }} - - name: Cloudfront invalidation - run: | - aws cloudfront create-invalidation --distribution-id ${{ vars.PROD_AWS_CLOUDFRONT_DISTRIBUTION_ID }} --paths "/*" - +env: + SLACK_CHANNEL: ${{ vars.SLACK_CHANNEL }} + AWS_BUCKET: ${{ vars.PROD_AWS_BUCKET }} + AWS_BUCKET_ARTIFACT: ${{ vars.PROD_AWS_BUCKET_ARTIFACT }} +jobs: - notify: - if: ${{ always() }} - needs: [ download_unzip_deploy ] - runs-on: ubuntu-latest - steps: - - name: Notify Slack - uses: steplix/cicd-notify@0.0.17 - with: - template: 'push' - status: ${{ needs.download_unzip_deploy.result}} - slack_webhook_url: ${{ secrets.SLACK_WEBHOOK }} \ No newline at end of file + production: + uses: steplix/cicd-steplix/.github/workflows/web-s3-release-deploy.yml@feature/addStaticWebWorkflows + with: + NODE_VERSION: ${{ env.NODE_VERSION }} + AWS_BUCKET: ${{ env.AWS_BUCKET }} + AWS_BUCKET_ARTIFACT: ${{ env.AWS_BUCKET_ARTIFACT }} + SLACK_CHANNEL: ${{ env.SLACK_CHANNEL }} + secrets: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} + AWS_KEY_ID: ${{ secrets.PROD_AWS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.PROD_AWS_SECRET_ACCESS_KEY }} + AWS_REGION: ${{ secrets.PROD_AWS_REGION }} + AWS_CLOUDFRONT_DISTRIBUTION_ID: ${{ vars.PROD_AWS_CLOUDFRONT_DISTRIBUTION_ID }} diff --git a/web/static-s3/github/web-s3-testing-deploy-cicd.yml b/web/static-s3/github/web-s3-testing-deploy-cicd.yml index 63d9268..cfc81bc 100644 --- a/web/static-s3/github/web-s3-testing-deploy-cicd.yml +++ b/web/static-s3/github/web-s3-testing-deploy-cicd.yml @@ -6,48 +6,25 @@ on: branches: - testing +env: + NODE_VERSION: ${{ vars.NODE_VERSION }} + DESTINATION_PR: ${{ vars.DESTINATION_PR_ON_TESTING_WORKFLOW }} + PR_TITLE: " is TAG VERSION INCREMENT: PUSHING testing INTO ${{ vars.DESTINATION_PR_ON_TESTING_WORKFLOW }}" + SLACK_CHANNEL: ${{ vars.SLACK_CHANNEL }} + AWS_BUCKET: ${{ vars.TEST_AWS_BUCKET }} jobs: - build_deploy: - runs-on: ubuntu-latest - steps: - #BUILD - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - node-version: ${{ vars.NODE_VERSION }} - - run: npm ci - - run: npm run release - #UPLOAD - - uses: aws-actions/configure-aws-credentials@v1.7.0 - with: - aws-access-key-id: ${{ secrets.TEST_AWS_KEY_ID }} - aws-secret-access-key: ${{ secrets.TEST_AWS_SECRET_ACCESS_KEY }} - aws-region: ${{ secrets.TEST_AWS_REGION }} - - name: copy files to S3 - run: | - aws s3 sync out s3://${{ vars.TEST_AWS_BUCKET }} - - name: Cloudfront invalidation - run: | - aws cloudfront create-invalidation --distribution-id ${{ vars.TEST_AWS_CLOUDFRONT_DISTRIBUTION_ID }} --paths "/*" - - - generate-pr: - needs: build_deploy - uses: steplix/cicd-steplix/.github/workflows/web-s3-generate-pr.yml@main + testing: + uses: steplix/cicd-steplix/.github/workflows/web-s3-testing-deploy.yml@feature/addStaticWebWorkflows with: - destination-branch-name: ${{ vars.DESTINATION_PR_ON_TESTING_WORKFLOW }} - pr-title: " is TAG VERSION INCREMENT: PUSHING testing INTO ${{ vars.DESTINATION_PR_ON_TESTING_WORKFLOW }}" - - notify: - if: ${{ always() }} - needs: [ build_deploy,generate-pr ] - runs-on: ubuntu-latest - steps: - - name: Notify Slack - uses: steplix/cicd-notify@0.0.17 - with: - template: 'push' - status: ${{ needs.build_deploy.result || needs.generate-pr.result }} - slack_webhook_url: ${{ secrets.SLACK_WEBHOOK }} \ No newline at end of file + NODE_VERSION: ${{ env.NODE_VERSION }} + DESTINATION_PR: ${{ env.DESTINATION_PR }} + PR_TITLE: ${{ env.PR_TITLE }} + SLACK_CHANNEL: ${{ env.SLACK_CHANNEL }} + secrets: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} + AWS_KEY_ID: ${{ secrets.TEST_AWS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.TEST_AWS_SECRET_ACCESS_KEY }} + AWS_REGION: ${{ secrets.TEST_AWS_REGION }} + AWS_CLOUDFRONT_DISTRIBUTION_ID: ${{ vars.TEST_AWS_CLOUDFRONT_DISTRIBUTION_ID }} From 885ad4befc803e59a6b83f969ad1c348ce2e7643 Mon Sep 17 00:00:00 2001 From: leandro Date: Tue, 18 Apr 2023 20:10:52 +0200 Subject: [PATCH 31/44] fix references problems --- .github/workflows/web-s3-release-deploy.yml | 2 +- .github/workflows/web-s3-testing-deploy.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/web-s3-release-deploy.yml b/.github/workflows/web-s3-release-deploy.yml index f305220..389f3ef 100644 --- a/.github/workflows/web-s3-release-deploy.yml +++ b/.github/workflows/web-s3-release-deploy.yml @@ -65,7 +65,7 @@ jobs: aws s3 sync output s3://${{ inputs.AWS_BUCKET }} - name: Cloudfront invalidation run: | - aws cloudfront create-invalidation --distribution-id ${{ inputs.AWS_CLOUDFRONT_DISTRIBUTION_ID }} --paths "/*" + aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_CLOUDFRONT_DISTRIBUTION_ID }} --paths "/*" diff --git a/.github/workflows/web-s3-testing-deploy.yml b/.github/workflows/web-s3-testing-deploy.yml index fd267a5..3fa4308 100644 --- a/.github/workflows/web-s3-testing-deploy.yml +++ b/.github/workflows/web-s3-testing-deploy.yml @@ -63,7 +63,7 @@ jobs: aws s3 sync out s3://${{ inputs.AWS_BUCKET }} - name: Cloudfront invalidation run: | - aws cloudfront create-invalidation --distribution-id ${{ inputs.AWS_CLOUDFRONT_DISTRIBUTION_ID }} --paths "/*" + aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_CLOUDFRONT_DISTRIBUTION_ID }} --paths "/*" generate-pr: From 9684bd2c2ab998b019dfac1032f613af6e9533d3 Mon Sep 17 00:00:00 2001 From: leandro Date: Fri, 21 Apr 2023 14:36:11 +0200 Subject: [PATCH 32/44] testing --- .github/workflows/web-s3-testing-deploy.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/web-s3-testing-deploy.yml b/.github/workflows/web-s3-testing-deploy.yml index 3fa4308..03a3f1d 100644 --- a/.github/workflows/web-s3-testing-deploy.yml +++ b/.github/workflows/web-s3-testing-deploy.yml @@ -46,6 +46,7 @@ jobs: runs-on: ubuntu-latest steps: #BUILD + - run: echo "aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_CLOUDFRONT_DISTRIBUTION_ID }} --paths /*" - uses: actions/checkout@v3 - uses: actions/setup-node@v3 with: From 0ee90e65b71e97bf5341503256abbfe0e1de8174 Mon Sep 17 00:00:00 2001 From: leandro Date: Fri, 21 Apr 2023 14:40:55 +0200 Subject: [PATCH 33/44] debuggin --- .github/workflows/web-s3-testing-deploy.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/web-s3-testing-deploy.yml b/.github/workflows/web-s3-testing-deploy.yml index 03a3f1d..bd1e838 100644 --- a/.github/workflows/web-s3-testing-deploy.yml +++ b/.github/workflows/web-s3-testing-deploy.yml @@ -28,6 +28,10 @@ on: type: string description: Bucket S3 to copy files for deploy required: true + AWS_CLOUDFRONT: + type: string + description: Only for test + required: true secrets: SLACK_WEBHOOK_URL: required: true @@ -47,6 +51,7 @@ jobs: steps: #BUILD - run: echo "aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_CLOUDFRONT_DISTRIBUTION_ID }} --paths /*" + - run: echo "aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_CLOUDFRONT_DISTRIBUTION_ID }} --paths /*" - uses: actions/checkout@v3 - uses: actions/setup-node@v3 with: From fc339dec72d719e1cae3bbf376d18c14f40795ed Mon Sep 17 00:00:00 2001 From: leandro Date: Fri, 21 Apr 2023 14:46:22 +0200 Subject: [PATCH 34/44] prueba --- .github/workflows/web-s3-testing-deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/web-s3-testing-deploy.yml b/.github/workflows/web-s3-testing-deploy.yml index bd1e838..3cb1888 100644 --- a/.github/workflows/web-s3-testing-deploy.yml +++ b/.github/workflows/web-s3-testing-deploy.yml @@ -51,7 +51,7 @@ jobs: steps: #BUILD - run: echo "aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_CLOUDFRONT_DISTRIBUTION_ID }} --paths /*" - - run: echo "aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_CLOUDFRONT_DISTRIBUTION_ID }} --paths /*" + - run: echo "aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_CLOUDFRONT }} --paths /*" - uses: actions/checkout@v3 - uses: actions/setup-node@v3 with: From a9c202e16b2d4059e9be79b06b13f13e891bdfb3 Mon Sep 17 00:00:00 2001 From: leandro Date: Fri, 21 Apr 2023 14:47:23 +0200 Subject: [PATCH 35/44] debug --- .github/workflows/web-s3-testing-deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/web-s3-testing-deploy.yml b/.github/workflows/web-s3-testing-deploy.yml index 3cb1888..8d6d655 100644 --- a/.github/workflows/web-s3-testing-deploy.yml +++ b/.github/workflows/web-s3-testing-deploy.yml @@ -69,7 +69,7 @@ jobs: aws s3 sync out s3://${{ inputs.AWS_BUCKET }} - name: Cloudfront invalidation run: | - aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_CLOUDFRONT_DISTRIBUTION_ID }} --paths "/*" + aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_CLOUDFRONT }} --paths "/*" generate-pr: From 7c01799023ccd2800e6de11a36e7838542713fa8 Mon Sep 17 00:00:00 2001 From: leandro Date: Fri, 21 Apr 2023 15:01:08 +0200 Subject: [PATCH 36/44] Fix reference problem --- .github/workflows/web-s3-release-deploy.yml | 8 +++++--- .github/workflows/web-s3-testing-deploy.yml | 10 +++------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/.github/workflows/web-s3-release-deploy.yml b/.github/workflows/web-s3-release-deploy.yml index 389f3ef..9c83be7 100644 --- a/.github/workflows/web-s3-release-deploy.yml +++ b/.github/workflows/web-s3-release-deploy.yml @@ -17,6 +17,10 @@ on: type: string description: Bucket S3 to download artifact to deploy required: true + AWS_CLOUDFRONT_DISTRIBUTION_ID: + type: string + description: CloudFront Distribution ID + required: true secrets: SLACK_WEBHOOK_URL: required: true @@ -26,8 +30,6 @@ on: required: true AWS_REGION: required: true - AWS_CLOUDFRONT_DISTRIBUTION_ID: - required: true jobs: @@ -65,7 +67,7 @@ jobs: aws s3 sync output s3://${{ inputs.AWS_BUCKET }} - name: Cloudfront invalidation run: | - aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_CLOUDFRONT_DISTRIBUTION_ID }} --paths "/*" + aws cloudfront create-invalidation --distribution-id ${{ inputs.AWS_CLOUDFRONT_DISTRIBUTION_ID }} --paths "/*" diff --git a/.github/workflows/web-s3-testing-deploy.yml b/.github/workflows/web-s3-testing-deploy.yml index 8d6d655..81dda3a 100644 --- a/.github/workflows/web-s3-testing-deploy.yml +++ b/.github/workflows/web-s3-testing-deploy.yml @@ -28,9 +28,9 @@ on: type: string description: Bucket S3 to copy files for deploy required: true - AWS_CLOUDFRONT: + AWS_CLOUDFRONT_DISTRIBUTION_ID: type: string - description: Only for test + description: CloudFront Distribution ID required: true secrets: SLACK_WEBHOOK_URL: @@ -41,8 +41,6 @@ on: required: true AWS_REGION: required: true - AWS_CLOUDFRONT_DISTRIBUTION_ID: - required: true jobs: @@ -50,8 +48,6 @@ jobs: runs-on: ubuntu-latest steps: #BUILD - - run: echo "aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_CLOUDFRONT_DISTRIBUTION_ID }} --paths /*" - - run: echo "aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_CLOUDFRONT }} --paths /*" - uses: actions/checkout@v3 - uses: actions/setup-node@v3 with: @@ -69,7 +65,7 @@ jobs: aws s3 sync out s3://${{ inputs.AWS_BUCKET }} - name: Cloudfront invalidation run: | - aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_CLOUDFRONT }} --paths "/*" + aws cloudfront create-invalidation --distribution-id ${{ inputs.AWS_CLOUDFRONT_DISTRIBUTION_ID }} --paths "/*" generate-pr: From cf5bfe86cf6edffded3999cbeb06c062d7cac339 Mon Sep 17 00:00:00 2001 From: leandro Date: Fri, 21 Apr 2023 15:31:36 +0200 Subject: [PATCH 37/44] fix bug --- .github/workflows/web-s3-hotfix-push.yml | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/.github/workflows/web-s3-hotfix-push.yml b/.github/workflows/web-s3-hotfix-push.yml index bb472c4..98ccd18 100644 --- a/.github/workflows/web-s3-hotfix-push.yml +++ b/.github/workflows/web-s3-hotfix-push.yml @@ -31,9 +31,16 @@ on: jobs: testing: - uses: steplix/cicd-steplix/.github/workflows/web-s3-validate.yml@main - with: - node-version: ${{ inputs.NODE_VERSION }} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: ${{ inputs.NODE_VERSION }} + - run: npm ci + - run: npm run lint --if-present + - run: npm run test --if-present + - run: echo "TEST SUCCESSFULLY" build: needs: [ testing ] From 9a32bfe9cebd54f0e6d8a63ed3b07f8e9ea92795 Mon Sep 17 00:00:00 2001 From: leandro Date: Fri, 21 Apr 2023 15:44:10 +0200 Subject: [PATCH 38/44] fix bug --- .github/workflows/web-s3-release-deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/web-s3-release-deploy.yml b/.github/workflows/web-s3-release-deploy.yml index 9c83be7..a840c65 100644 --- a/.github/workflows/web-s3-release-deploy.yml +++ b/.github/workflows/web-s3-release-deploy.yml @@ -61,7 +61,7 @@ jobs: with: aws-access-key-id: ${{ secrets.PROD_AWS_KEY_ID }} aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - aws-region: ${{ secrets.PROD_AWS_REGION }} + aws-region: ${{ secrets.AWS_REGION }} - name: copy files to S3 run: | aws s3 sync output s3://${{ inputs.AWS_BUCKET }} From 004854f1fcb67cc49fe31c166605cf62e92a2e9a Mon Sep 17 00:00:00 2001 From: leandro Date: Fri, 21 Apr 2023 15:46:16 +0200 Subject: [PATCH 39/44] push --- .../github/web-s3-develop-push-cicd.yml | 13 ++++--------- .../github/web-s3-hotfix-push-cicd.yml | 17 +++++------------ ...cicd.yml => web-s3-production-push-cicd.yml} | 11 +++-------- .../web-s3-realease-production-deploy-cicd.yml | 14 ++++---------- .../github/web-s3-testing-deploy-cicd.yml | 17 ++++++----------- 5 files changed, 22 insertions(+), 50 deletions(-) rename web/static-s3/github/{web-s3-master-push-cicd.yml => web-s3-production-push-cicd.yml} (64%) diff --git a/web/static-s3/github/web-s3-develop-push-cicd.yml b/web/static-s3/github/web-s3-develop-push-cicd.yml index b92cfad..60cf50b 100644 --- a/web/static-s3/github/web-s3-develop-push-cicd.yml +++ b/web/static-s3/github/web-s3-develop-push-cicd.yml @@ -7,20 +7,15 @@ on: branches: - develop -env: - NODE_VERSION: ${{ vars.NODE_VERSION }} - DESTINATION_PR: ${{ vars.DESTINATION_PR_ON_DEVELOP_WORKFLOW }} - PR_TITLE: "Pushing develop into ${{ vars.DESTINATION_PR_ON_DEVELOP_WORKFLOW }}" - SLACK_CHANNEL: ${{ vars.SLACK_CHANNEL }} jobs: develop: uses: steplix/cicd-steplix/.github/workflows/web-s3-develop-push.yml@feature/addStaticWebWorkflows with: - NODE_VERSION: ${{ env.NODE_VERSION }} - DESTINATION_PR: ${{ env.DESTINATION_PR }} - PR_TITLE: ${{ env.PR_TITLE }} - SLACK_CHANNEL: ${{ env.SLACK_CHANNEL }} + NODE_VERSION: ${{ vars.NODE_VERSION }} + DESTINATION_PR: ${{ vars.DESTINATION_PR_ON_DEVELOP_WORKFLOW }} + PR_TITLE: "Pushing develop into ${{ vars.DESTINATION_PR_ON_DEVELOP_WORKFLOW }}" + SLACK_CHANNEL: ${{ vars.SLACK_CHANNEL }} secrets: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} diff --git a/web/static-s3/github/web-s3-hotfix-push-cicd.yml b/web/static-s3/github/web-s3-hotfix-push-cicd.yml index dadbcde..cf18af4 100644 --- a/web/static-s3/github/web-s3-hotfix-push-cicd.yml +++ b/web/static-s3/github/web-s3-hotfix-push-cicd.yml @@ -7,20 +7,13 @@ on: branches: - 'hotfix/**' -env: - NODE_VERSION: ${{ vars.NODE_VERSION }} - DESTINATION_PR_MASTER: ${{ vars.DESTINATION_PR_ON_TESTING_WORKFLOW }} - DESTINATION_PR_DEVELOP: develop - SLACK_CHANNEL: ${{ vars.SLACK_CHANNEL }} - jobs: - hotfix: - uses: steplix/cicd-steplix/.github/workflows/web-s3-develop-push.yml@feature/addStaticWebWorkflows + uses: steplix/cicd-steplix/.github/workflows/web-s3-hotfix-push.yml@feature/addStaticWebWorkflows with: - NODE_VERSION: ${{ env.NODE_VERSION }} - DESTINATION_PR_MASTER: ${{ env.DESTINATION_PR_MASTER }} - DESTINATION_PR_DEVELOP: ${{ env.DESTINATION_PR_DEVELOP }} - SLACK_CHANNEL: ${{ env.SLACK_CHANNEL }} + NODE_VERSION: ${{ vars.NODE_VERSION }} + DESTINATION_PR_MASTER: ${{ vars.DESTINATION_PR_ON_TESTING_WORKFLOW }} + DESTINATION_PR_DEVELOP: develop + SLACK_CHANNEL: ${{ vars.SLACK_CHANNEL }} secrets: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} diff --git a/web/static-s3/github/web-s3-master-push-cicd.yml b/web/static-s3/github/web-s3-production-push-cicd.yml similarity index 64% rename from web/static-s3/github/web-s3-master-push-cicd.yml rename to web/static-s3/github/web-s3-production-push-cicd.yml index e593e7a..55aaf62 100644 --- a/web/static-s3/github/web-s3-master-push-cicd.yml +++ b/web/static-s3/github/web-s3-production-push-cicd.yml @@ -8,19 +8,14 @@ on: - master -env: - NODE_VERSION: ${{ vars.NODE_VERSION }} - SLACK_CHANNEL: ${{ vars.SLACK_CHANNEL }} - AWS_BUCKET: ${{ vars.PROD_AWS_BUCKET_ARTIFACT }} - jobs: master: uses: steplix/cicd-steplix/.github/workflows/web-s3-master-push.yml@feature/addStaticWebWorkflows with: - NODE_VERSION: ${{ env.NODE_VERSION }} - SLACK_CHANNEL: ${{ env.SLACK_CHANNEL }} - AWS_BUCKET: ${{ env.AWS_BUCKET }} + NODE_VERSION: ${{ vars.NODE_VERSION }} + SLACK_CHANNEL: ${{ vars.SLACK_CHANNEL }} + AWS_BUCKET: ${{ vars.PROD_AWS_BUCKET_ARTIFACT }} secrets: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} AWS_KEY_ID: ${{ secrets.TEST_AWS_KEY_ID }} diff --git a/web/static-s3/github/web-s3-realease-production-deploy-cicd.yml b/web/static-s3/github/web-s3-realease-production-deploy-cicd.yml index 56d6bd4..4fc5157 100644 --- a/web/static-s3/github/web-s3-realease-production-deploy-cicd.yml +++ b/web/static-s3/github/web-s3-realease-production-deploy-cicd.yml @@ -6,23 +6,17 @@ on: types: [published] -env: - SLACK_CHANNEL: ${{ vars.SLACK_CHANNEL }} - AWS_BUCKET: ${{ vars.PROD_AWS_BUCKET }} - AWS_BUCKET_ARTIFACT: ${{ vars.PROD_AWS_BUCKET_ARTIFACT }} - jobs: production: uses: steplix/cicd-steplix/.github/workflows/web-s3-release-deploy.yml@feature/addStaticWebWorkflows with: - NODE_VERSION: ${{ env.NODE_VERSION }} - AWS_BUCKET: ${{ env.AWS_BUCKET }} - AWS_BUCKET_ARTIFACT: ${{ env.AWS_BUCKET_ARTIFACT }} - SLACK_CHANNEL: ${{ env.SLACK_CHANNEL }} + AWS_BUCKET: ${{ vars.PROD_AWS_BUCKET }} + AWS_BUCKET_ARTIFACT: ${{ vars.PROD_AWS_BUCKET_ARTIFACT }} + SLACK_CHANNEL: ${{ vars.SLACK_CHANNEL }} + AWS_CLOUDFRONT_DISTRIBUTION_ID: ${{ vars.PROD_AWS_CLOUDFRONT_DISTRIBUTION_ID }} secrets: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} AWS_KEY_ID: ${{ secrets.PROD_AWS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.PROD_AWS_SECRET_ACCESS_KEY }} AWS_REGION: ${{ secrets.PROD_AWS_REGION }} - AWS_CLOUDFRONT_DISTRIBUTION_ID: ${{ vars.PROD_AWS_CLOUDFRONT_DISTRIBUTION_ID }} diff --git a/web/static-s3/github/web-s3-testing-deploy-cicd.yml b/web/static-s3/github/web-s3-testing-deploy-cicd.yml index cfc81bc..308c05c 100644 --- a/web/static-s3/github/web-s3-testing-deploy-cicd.yml +++ b/web/static-s3/github/web-s3-testing-deploy-cicd.yml @@ -6,25 +6,20 @@ on: branches: - testing -env: - NODE_VERSION: ${{ vars.NODE_VERSION }} - DESTINATION_PR: ${{ vars.DESTINATION_PR_ON_TESTING_WORKFLOW }} - PR_TITLE: " is TAG VERSION INCREMENT: PUSHING testing INTO ${{ vars.DESTINATION_PR_ON_TESTING_WORKFLOW }}" - SLACK_CHANNEL: ${{ vars.SLACK_CHANNEL }} - AWS_BUCKET: ${{ vars.TEST_AWS_BUCKET }} jobs: testing: uses: steplix/cicd-steplix/.github/workflows/web-s3-testing-deploy.yml@feature/addStaticWebWorkflows with: - NODE_VERSION: ${{ env.NODE_VERSION }} - DESTINATION_PR: ${{ env.DESTINATION_PR }} - PR_TITLE: ${{ env.PR_TITLE }} - SLACK_CHANNEL: ${{ env.SLACK_CHANNEL }} + NODE_VERSION: ${{ vars.NODE_VERSION }} + DESTINATION_PR: ${{ vars.DESTINATION_PR_ON_TESTING_WORKFLOW }} + PR_TITLE: " is TAG VERSION INCREMENT: PUSHING testing INTO ${{ vars.DESTINATION_PR_ON_TESTING_WORKFLOW }}" + SLACK_CHANNEL: ${{ vars.SLACK_CHANNEL }} + AWS_BUCKET: ${{ vars.TEST_AWS_BUCKET }} + AWS_CLOUDFRONT_DISTRIBUTION_ID: ${{ vars.TEST_AWS_CLOUDFRONT_DISTRIBUTION_ID }} secrets: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} AWS_KEY_ID: ${{ secrets.TEST_AWS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.TEST_AWS_SECRET_ACCESS_KEY }} AWS_REGION: ${{ secrets.TEST_AWS_REGION }} - AWS_CLOUDFRONT_DISTRIBUTION_ID: ${{ vars.TEST_AWS_CLOUDFRONT_DISTRIBUTION_ID }} From a46fc34fad8b9f81458e016f80318d3fba2df631 Mon Sep 17 00:00:00 2001 From: leandro Date: Fri, 21 Apr 2023 15:48:02 +0200 Subject: [PATCH 40/44] fix --- .github/workflows/web-s3-release-deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/web-s3-release-deploy.yml b/.github/workflows/web-s3-release-deploy.yml index a840c65..e6c211f 100644 --- a/.github/workflows/web-s3-release-deploy.yml +++ b/.github/workflows/web-s3-release-deploy.yml @@ -59,7 +59,7 @@ jobs: #UPLOAD - uses: aws-actions/configure-aws-credentials@v1.7.0 with: - aws-access-key-id: ${{ secrets.PROD_AWS_KEY_ID }} + aws-access-key-id: ${{ secrets.AWS_KEY_ID }} aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} aws-region: ${{ secrets.AWS_REGION }} - name: copy files to S3 From 5907f15032108ac3d43179eaac18650059750615 Mon Sep 17 00:00:00 2001 From: leandro Date: Mon, 24 Apr 2023 17:00:08 +0200 Subject: [PATCH 41/44] test --- .github/workflows/web-s3-release-deploy.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/web-s3-release-deploy.yml b/.github/workflows/web-s3-release-deploy.yml index e6c211f..56c6de8 100644 --- a/.github/workflows/web-s3-release-deploy.yml +++ b/.github/workflows/web-s3-release-deploy.yml @@ -57,11 +57,7 @@ jobs: run: tar -xvzf ${{ github.event.release.tag_name }}.tar.gz -C output #UPLOAD - - uses: aws-actions/configure-aws-credentials@v1.7.0 - with: - aws-access-key-id: ${{ secrets.AWS_KEY_ID }} - aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - aws-region: ${{ secrets.AWS_REGION }} + - name: copy files to S3 run: | aws s3 sync output s3://${{ inputs.AWS_BUCKET }} From 68e3f474f2e2dfbbbd7c0b7445d3b36a9619ce8b Mon Sep 17 00:00:00 2001 From: leandro Date: Tue, 25 Apr 2023 19:00:10 +0200 Subject: [PATCH 42/44] fix event --- web/static-s3/github/web-s3-production-push-cicd.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/web/static-s3/github/web-s3-production-push-cicd.yml b/web/static-s3/github/web-s3-production-push-cicd.yml index 55aaf62..43a5b49 100644 --- a/web/static-s3/github/web-s3-production-push-cicd.yml +++ b/web/static-s3/github/web-s3-production-push-cicd.yml @@ -3,7 +3,9 @@ run-name: > ${{ github.event.pull_request.title }} on: - push: + pull_request_target: + types: + - closed branches: - master @@ -16,8 +18,11 @@ jobs: NODE_VERSION: ${{ vars.NODE_VERSION }} SLACK_CHANNEL: ${{ vars.SLACK_CHANNEL }} AWS_BUCKET: ${{ vars.PROD_AWS_BUCKET_ARTIFACT }} + TEXT-WHERE-SEARCH-FOR-PARAMETERS: ${{ github.event.pull_request.title }} + secrets: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} AWS_KEY_ID: ${{ secrets.TEST_AWS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.TEST_AWS_SECRET_ACCESS_KEY }} AWS_REGION: ${{ secrets.TEST_AWS_REGION }} + From 98b3cb7526473594455d72f51d159e1bdff75066 Mon Sep 17 00:00:00 2001 From: leandro Date: Fri, 28 Apr 2023 11:57:55 +0200 Subject: [PATCH 43/44] changes --- .github/workflows/web-s3-develop-push.yml | 16 +++----- .github/workflows/web-s3-hotfix-push.yml | 41 ++++++++++++------- .github/workflows/web-s3-testing-deploy.yml | 38 +++++++++-------- .../github/web-s3-testing-deploy-cicd.yml | 1 - 4 files changed, 54 insertions(+), 42 deletions(-) diff --git a/.github/workflows/web-s3-develop-push.yml b/.github/workflows/web-s3-develop-push.yml index 37557e3..afd53e0 100644 --- a/.github/workflows/web-s3-develop-push.yml +++ b/.github/workflows/web-s3-develop-push.yml @@ -66,16 +66,12 @@ jobs: destination_branch: ${{ inputs.DESTINATION_PR }} pr_title: ${{ inputs.PR_TITLE }} - run: echo "PR GENERATED SUCCESSFULLY" - - notify: - if: ${{ always() }} - needs: [testing, build, generate-pr] - runs-on: ubuntu-latest - steps: - name: Notify Slack uses: steplix/cicd-notify@1.0.0 with: - template: 'push' - status: ${{ needs.testing.result || needs.build.result || needs.generate-pr.result }} - slack_webhook_url: ${{ secrets.SLACK_WEBHOOK_URL }} - channel: ${{ inputs.SLACK_CHANNEL }} \ No newline at end of file + template: pr + status: ${{ job.status }} + channel: ${{ inputs.SLACK_CHANNEL }} + env: + PR_URL: ${{ steps.open-pr.outputs.pr_url }} + PR_NUMBER: ${{ steps.open-pr.outputs.pr_number }} diff --git a/.github/workflows/web-s3-hotfix-push.yml b/.github/workflows/web-s3-hotfix-push.yml index 98ccd18..edb19bd 100644 --- a/.github/workflows/web-s3-hotfix-push.yml +++ b/.github/workflows/web-s3-hotfix-push.yml @@ -59,12 +59,21 @@ jobs: steps: - uses: actions/checkout@v3 - name: generate-pr - id: open-pr + id: pr-to-main uses: repo-sync/pull-request@v2 with: destination_branch: ${{ inputs.DESTINATION_PR_MASTER }} pr_title: " is TAG VERSION INCREMENT: Pushing HOTFIX ${{ github.ref_name }} into ${{ inputs.DESTINATION_PR_MASTER }}" - - run: echo "PR GENERATED SUCCESSFULLY" + - run: echo "PR TO ${{ inputs.DESTINATION_PR_MASTER }} GENERATED SUCCESSFULLY" + - name: Notify Slack + uses: steplix/cicd-notify@1.0.0 + with: + template: pr + status: ${{ job.status }} + channel: ${{ inputs.SLACK_CHANNEL }} + env: + PR_URL: ${{ steps.pr-to-main.outputs.pr_url }} + PR_NUMBER: ${{ steps.pr-to-main.outputs.pr_number }} generate-pr-to-develop: needs: [testing,build] @@ -78,15 +87,19 @@ jobs: destination_branch: ${{ inputs.DESTINATION_PR_DEVELOP }} pr-title: "Pushing HOTFIX ${{ github.ref_name }} into ${{ inputs.DESTINATION_PR_DEVELOP }}" - notify: - if: ${{ always() }} - needs: [ testing,build,generate-pr-to-master,generate-pr-to-develop ] - runs-on: ubuntu-latest - steps: - - name: Notify Slack - uses: steplix/cicd-notify@1.0.0 - with: - template: 'push' - status: ${{ needs.testing.result || needs.build.result || needs.generate-pr-to-master.result || needs.generate-pr-to-develop.result }} - slack_webhook_url: ${{ secrets.SLACK_WEBHOOK }} - channel: ${{ inputs.SLACK_CHANNEL }} \ No newline at end of file + notify-failure: + runs-on: ubuntu-latest + needs: + - testing + - build + - generate-pr-to-master + - generate-pr-to-develop + if: failure() + continue-on-error: true + steps: + - name: Slack Notify + uses: steplix/cicd-notify@1.0.0 + with: + template: push + status: failure + channel: ${{ env.SLACK_CHANNEL }} \ No newline at end of file diff --git a/.github/workflows/web-s3-testing-deploy.yml b/.github/workflows/web-s3-testing-deploy.yml index 81dda3a..4d31164 100644 --- a/.github/workflows/web-s3-testing-deploy.yml +++ b/.github/workflows/web-s3-testing-deploy.yml @@ -15,11 +15,6 @@ on: type: string default: master required: false - PR_TITLE: - type: string - description: "Title for the pr" - default: "Pushing testing" - required: false SLACK_CHANNEL: type: string description: Slack channel to send notifications @@ -74,22 +69,31 @@ jobs: steps: - uses: actions/checkout@v3 - name: generate-pr - id: open-pr + id: pr-to-main uses: repo-sync/pull-request@v2 with: destination_branch: ${{ inputs.DESTINATION_PR }} - pr_title: ${{ inputs.PR_TITLE }} + pr_title: " is TAG VERSION INCREMENT: PUSHING testing INTO ${{ inputs.DESTINATION_PR }}" - run: echo "PR GENERATED SUCCESSFULLY" - - notify: - if: ${{ always() }} - needs: [ build_deploy,generate-pr ] - runs-on: ubuntu-latest - steps: - name: Notify Slack uses: steplix/cicd-notify@1.0.0 with: - template: 'push' - status: ${{ needs.build_deploy.result || needs.generate-pr.result }} - slack_webhook_url: ${{ secrets.SLACK_WEBHOOK }} - channel: ${{ inputs.SLACK_CHANNEL }} \ No newline at end of file + template: pr + status: ${{ job.status }} + channel: ${{ inputs.SLACK_CHANNEL }} + env: + PR_URL: ${{ steps.pr-to-main.outputs.pr_url }} + PR_NUMBER: ${{ steps.pr-to-main.outputs.pr_number }} + + notify-failure: + runs-on: ubuntu-latest + needs: [ build_deploy,generate-pr ] + if: failure() + continue-on-error: true + steps: + - name: Slack Notify + uses: steplix/cicd-notify@1.0.0 + with: + template: push + status: failure + channel: ${{ env.SLACK_CHANNEL }} \ No newline at end of file diff --git a/web/static-s3/github/web-s3-testing-deploy-cicd.yml b/web/static-s3/github/web-s3-testing-deploy-cicd.yml index 308c05c..ac83d9c 100644 --- a/web/static-s3/github/web-s3-testing-deploy-cicd.yml +++ b/web/static-s3/github/web-s3-testing-deploy-cicd.yml @@ -14,7 +14,6 @@ jobs: with: NODE_VERSION: ${{ vars.NODE_VERSION }} DESTINATION_PR: ${{ vars.DESTINATION_PR_ON_TESTING_WORKFLOW }} - PR_TITLE: " is TAG VERSION INCREMENT: PUSHING testing INTO ${{ vars.DESTINATION_PR_ON_TESTING_WORKFLOW }}" SLACK_CHANNEL: ${{ vars.SLACK_CHANNEL }} AWS_BUCKET: ${{ vars.TEST_AWS_BUCKET }} AWS_CLOUDFRONT_DISTRIBUTION_ID: ${{ vars.TEST_AWS_CLOUDFRONT_DISTRIBUTION_ID }} From d79a0f3c5b1e99e033832be0a43f7813a42c54db Mon Sep 17 00:00:00 2001 From: lalvarez12 Date: Tue, 25 Jul 2023 18:35:50 +0200 Subject: [PATCH 44/44] notify on error --- .github/workflows/web-s3-develop-push.yml | 17 +++++++++++- .github/workflows/web-s3-testing-deploy.yml | 30 +++++++++++---------- 2 files changed, 32 insertions(+), 15 deletions(-) diff --git a/.github/workflows/web-s3-develop-push.yml b/.github/workflows/web-s3-develop-push.yml index afd53e0..635003c 100644 --- a/.github/workflows/web-s3-develop-push.yml +++ b/.github/workflows/web-s3-develop-push.yml @@ -1,6 +1,6 @@ name: Push in development branch run-name: > - "Create PR FROM develop TO ${{ inputs.DESTINATION_PR_ON_DEVELOP_WORKFLOW }}: ${{ github.event.head_commit.message }}" + "Create PR FROM develop TO ${{ inputs.DESTINATION_PR }}: ${{ github.event.head_commit.message }}" on: workflow_call: @@ -72,6 +72,21 @@ jobs: template: pr status: ${{ job.status }} channel: ${{ inputs.SLACK_CHANNEL }} + slack_webhook_url: ${{ secrets.SLACK_WEBHOOK }} env: PR_URL: ${{ steps.open-pr.outputs.pr_url }} PR_NUMBER: ${{ steps.open-pr.outputs.pr_number }} + + + notify-failure: + if: failure() + needs: [ testing, build, generate-pr ] + runs-on: ubuntu-latest + steps: + - name: Notify Slack + uses: steplix/cicd-notify@1.0.0 + with: + template: 'push' + status: failure + slack_webhook_url: ${{ secrets.SLACK_WEBHOOK }} + channel: ${{ inputs.SLACK_CHANNEL }} \ No newline at end of file diff --git a/.github/workflows/web-s3-testing-deploy.yml b/.github/workflows/web-s3-testing-deploy.yml index 4d31164..eeff201 100644 --- a/.github/workflows/web-s3-testing-deploy.yml +++ b/.github/workflows/web-s3-testing-deploy.yml @@ -1,6 +1,6 @@ name: Push in testing branch run-name: > - "Deploying testing and creating PR to ${{ vars.DESTINATION_PR_ON_TESTING_WORKFLOW }}" + "Deploying testing and creating PR to ${{ inputs.DESTINATION_PR }}" on: workflow_call: @@ -73,7 +73,7 @@ jobs: uses: repo-sync/pull-request@v2 with: destination_branch: ${{ inputs.DESTINATION_PR }} - pr_title: " is TAG VERSION INCREMENT: PUSHING testing INTO ${{ inputs.DESTINATION_PR }}" + pr_title: "#patch is TAG VERSION INCREMENT: PUSHING testing INTO ${{ inputs.DESTINATION_PR }}" - run: echo "PR GENERATED SUCCESSFULLY" - name: Notify Slack uses: steplix/cicd-notify@1.0.0 @@ -81,19 +81,21 @@ jobs: template: pr status: ${{ job.status }} channel: ${{ inputs.SLACK_CHANNEL }} + slack_webhook_url: ${{ secrets.SLACK_WEBHOOK }} env: PR_URL: ${{ steps.pr-to-main.outputs.pr_url }} PR_NUMBER: ${{ steps.pr-to-main.outputs.pr_number }} - notify-failure: - runs-on: ubuntu-latest - needs: [ build_deploy,generate-pr ] - if: failure() - continue-on-error: true - steps: - - name: Slack Notify - uses: steplix/cicd-notify@1.0.0 - with: - template: push - status: failure - channel: ${{ env.SLACK_CHANNEL }} \ No newline at end of file + notify-failure: + runs-on: ubuntu-latest + needs: [ build_deploy,generate-pr ] + if: failure() + continue-on-error: true + steps: + - name: Slack Notify + uses: steplix/cicd-notify@1.0.0 + with: + template: push + status: failure + channel: ${{ inputs.SLACK_CHANNEL }} + slack_webhook_url: ${{ secrets.SLACK_WEBHOOK }} \ No newline at end of file