From 32d5edd80c9d1ba04475b61ae51b01a69d78c7c3 Mon Sep 17 00:00:00 2001 From: lukas Date: Wed, 30 Apr 2025 14:56:39 +0200 Subject: [PATCH 01/10] Adjust and add new worflow to the new deployment way --- .github/workflows/manually-trigger-deploy.yml | 53 ++++++++++++++++ .github/workflows/publish-new-build.yml | 32 +++++++++- .github/workflows/put-ssm-version-deploy.yml | 49 +++++++++++++++ ci/scripts/check-and-change-image.js | 63 +++++++++++++++++++ 4 files changed, 196 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/manually-trigger-deploy.yml create mode 100644 .github/workflows/put-ssm-version-deploy.yml create mode 100644 ci/scripts/check-and-change-image.js diff --git a/.github/workflows/manually-trigger-deploy.yml b/.github/workflows/manually-trigger-deploy.yml new file mode 100644 index 0000000..fedb727 --- /dev/null +++ b/.github/workflows/manually-trigger-deploy.yml @@ -0,0 +1,53 @@ +name: Manually trigger deploy to staging or production +run-name: "Manually deploy ${{ github.ref_name }} triggered by ${{ github.actor }}; version: ${{ inputs.version }}" + +on: + workflow_dispatch: + inputs: + version: + description: "Enter the version number" + required: true + default: "main" + environment: + required: false + description: "Select the environment to deploy to" + type: choice + options: + - staging + # TODO: uncomment this when we want to deploy to production + # - production + default: staging + +permissions: + id-token: write + contents: read + +jobs: + trigger-staging-deploy: + uses: ./.github/workflows/put-ssm-version-deploy.yml + if: | + ${{ inputs.version != '' && inputs.environment == 'staging' }} && + always() && + !contains(needs.*.result, 'failure') && + !contains(needs.*.result, 'cancelled') + with: + version: ${{ inputs.version }} + environment: staging + secrets-environment: staging-fidl + ecr-repository: filplus-backend + secrets: inherit + + # TODO: uncomment this when we want to deploy to production + # trigger-production-deploy: + # uses: ./.github/workflows/put-ssm-version-deploy.yml + # if: | + # ${{ inputs.version != '' && inputs.environment == 'production' }} && + # always() && + # !contains(needs.*.result, 'failure') && + # !contains(needs.*.result, 'cancelled') + # with: + # version: ${{ inputs.version }} + # environment: ${{ inputs.environment }} + # secrets-environment: production-fidl + # ecr-repository: filplus-backend + # secrets: inherit diff --git a/.github/workflows/publish-new-build.yml b/.github/workflows/publish-new-build.yml index 1d3c0be..eab92e4 100644 --- a/.github/workflows/publish-new-build.yml +++ b/.github/workflows/publish-new-build.yml @@ -13,6 +13,20 @@ on: description: "Enter the version number" required: true default: "latest" + deploy: + description: "Deploy the new version?" + required: false + type: boolean + default: false + environment: + required: false + description: "Select the environment to deploy to" + type: choice + options: + - staging + # TODO: uncomment this when we want to deploy to production + # - production + default: staging jobs: code-check: @@ -80,9 +94,25 @@ jobs: uses: actions/checkout@v4 with: ref: ${{ needs.bump-version.outputs.commit_sha }} - - name: Create and push tag run: | TAG_NAME="v${{ inputs.version }}" git tag $TAG_NAME git push origin $TAG_NAME + + trigger-deploy: + needs: + - code-check + - bump-version + - git-tag + uses: ./.github/workflows/put-ssm-version-deploy.yml + if: | + ${{ inputs.version != '' && inputs.deploy == true }} && + always() && + !contains(needs.*.result, 'failure') && + !contains(needs.*.result, 'cancelled') + with: + version: ${{ inputs.version }} + environment: ${{ inputs.environment }} + ecr-repository: filplus-backend + secrets: inherit diff --git a/.github/workflows/put-ssm-version-deploy.yml b/.github/workflows/put-ssm-version-deploy.yml new file mode 100644 index 0000000..ed07584 --- /dev/null +++ b/.github/workflows/put-ssm-version-deploy.yml @@ -0,0 +1,49 @@ +name: Put SSM version for deploy +run-name: "Put SSM version for ${{ github.ref_name }} triggered by ${{ github.actor }} for ${{ inputs.environment }}; version: ${{ inputs.version || 'N/A'}}" + +on: + workflow_call: + inputs: + version: + required: false + type: string + environment: + required: true + type: string + ecr-repository: + required: false + type: string + +jobs: + trigger-deploy: + runs-on: ubuntu-latest + env: + ECR_REPOSITORY: ${{ inputs.ecr-repository }} + SSM_PARAMETER_NAME: "/${{ inputs.environment }}/${{ inputs.ecr-repository }}/version" + IMAGE_VERSION: "${{ inputs.version }}" + ENVIRONMENT: "${{ inputs.environment }}" + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install Node.js + uses: actions/setup-node@v4 + with: + node-version: "20" + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_IMAGE_DEPLOYER }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_IMAGE_DEPLOYER }} + aws-region: us-east-1 + + - name: Login to Amazon ECR + uses: aws-actions/amazon-ecr-login@v2 + with: + mask-password: "true" + registry-type: public + + - name: Change ${{ env.ECR_REPOSITORY }} version to ${{ env.IMAGE_VERSION }} on ${{ inputs.environment }} in SSM parameter store + run: node ./ci/scripts/check-and-change-image.js diff --git a/ci/scripts/check-and-change-image.js b/ci/scripts/check-and-change-image.js new file mode 100644 index 0000000..56a00f4 --- /dev/null +++ b/ci/scripts/check-and-change-image.js @@ -0,0 +1,63 @@ +const { execSync } = require('child_process') + +const ECR_REPOSITORY = process.env.ECR_REPOSITORY +const IMAGE_VERSION = process.env.IMAGE_VERSION +const SSM_PARAMETER_NAME = process.env.SSM_PARAMETER_NAME +const ENVIRONMENT = process.env.ENVIRONMENT + +if (!ECR_REPOSITORY || !IMAGE_VERSION || !SSM_PARAMETER_NAME) { + console.error( + 'Missing environment variables: ECR_REPOSITORY, IMAGE_VERSION, SSM_PARAMETER_NAME', + ) + process.exit(1) +} + +function runCommand(command) { + try { + const output = execSync(command, { encoding: 'utf-8' }) + return JSON.parse(output) + } catch (error) { + console.error(`Error running command: ${command}`) + console.error(error.message) + } +} + +let currentVersions = runCommand( + `aws ssm get-parameter --name "${SSM_PARAMETER_NAME}" --query "Parameter.Value" --output json`, +) + +console.log('Current versions:', currentVersions) + +if (!currentVersions) { + console.error(`This app is not supported in this environment: ${ENVIRONMENT}`) + process.exit(1) +} + +console.log('Checking image in ECR...') + +const imageExist = runCommand( + `aws ecr-public describe-images --repository-name ${ECR_REPOSITORY} --region us-east-1 --image-ids imageTag=${IMAGE_VERSION}`, +) + +if (!imageExist || !imageExist.imageDetails) { + console.error(`Image ${IMAGE_VERSION} not found in ECR.`) + process.exit(1) +} + +console.log('Image was found in ECR:', imageExist) +console.log('Checking version in SSM...') + +const newCurrentSSMParam = IMAGE_VERSION + +console.log('New current SSM params:', newCurrentSSMParam) + +try { + const putNewVersion = `aws ssm put-parameter --name "${SSM_PARAMETER_NAME}" --value "${newCurrentSSMParam}" --type String --overwrite` + + execSync(putNewVersion, { stdio: 'inherit' }) + console.log(`Update version COMPLETE!`) + console.log(`Trigger the deployment process...`) +} catch (error) { + console.error(`Failed to put a new version:`, error.message) + process.exit(1) +} From e3df1f25f2e5f21f069b5babb09a7a2bcec094a0 Mon Sep 17 00:00:00 2001 From: lukas Date: Wed, 30 Apr 2025 14:58:43 +0200 Subject: [PATCH 02/10] Change the manually trigger deployment workflow --- .github/workflows/manually-trigger-deploy.yml | 22 +++---------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/.github/workflows/manually-trigger-deploy.yml b/.github/workflows/manually-trigger-deploy.yml index fedb727..bd315bd 100644 --- a/.github/workflows/manually-trigger-deploy.yml +++ b/.github/workflows/manually-trigger-deploy.yml @@ -23,31 +23,15 @@ permissions: contents: read jobs: - trigger-staging-deploy: + trigger-deploy: uses: ./.github/workflows/put-ssm-version-deploy.yml if: | - ${{ inputs.version != '' && inputs.environment == 'staging' }} && + ${{ inputs.version != '' && inputs.environment != '' }} && always() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') with: version: ${{ inputs.version }} - environment: staging - secrets-environment: staging-fidl + environment: ${{ inputs.environment }} ecr-repository: filplus-backend secrets: inherit - - # TODO: uncomment this when we want to deploy to production - # trigger-production-deploy: - # uses: ./.github/workflows/put-ssm-version-deploy.yml - # if: | - # ${{ inputs.version != '' && inputs.environment == 'production' }} && - # always() && - # !contains(needs.*.result, 'failure') && - # !contains(needs.*.result, 'cancelled') - # with: - # version: ${{ inputs.version }} - # environment: ${{ inputs.environment }} - # secrets-environment: production-fidl - # ecr-repository: filplus-backend - # secrets: inherit From 0cb0265c506c7e768d145154cb7271ed942a69c8 Mon Sep 17 00:00:00 2001 From: lukas Date: Wed, 30 Apr 2025 14:59:30 +0200 Subject: [PATCH 03/10] Add some changes --- .github/workflows/manually-trigger-deploy.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/manually-trigger-deploy.yml b/.github/workflows/manually-trigger-deploy.yml index bd315bd..0aa042c 100644 --- a/.github/workflows/manually-trigger-deploy.yml +++ b/.github/workflows/manually-trigger-deploy.yml @@ -25,11 +25,7 @@ permissions: jobs: trigger-deploy: uses: ./.github/workflows/put-ssm-version-deploy.yml - if: | - ${{ inputs.version != '' && inputs.environment != '' }} && - always() && - !contains(needs.*.result, 'failure') && - !contains(needs.*.result, 'cancelled') + if: ${{ inputs.version != '' && inputs.environment != '' }} && with: version: ${{ inputs.version }} environment: ${{ inputs.environment }} From 2b82acba52cc8b42f1ecb6f9dad580a26f820772 Mon Sep 17 00:00:00 2001 From: lukas Date: Wed, 30 Apr 2025 14:59:38 +0200 Subject: [PATCH 04/10] Add some changes --- .github/workflows/manually-trigger-deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/manually-trigger-deploy.yml b/.github/workflows/manually-trigger-deploy.yml index 0aa042c..f4b4eb1 100644 --- a/.github/workflows/manually-trigger-deploy.yml +++ b/.github/workflows/manually-trigger-deploy.yml @@ -25,7 +25,7 @@ permissions: jobs: trigger-deploy: uses: ./.github/workflows/put-ssm-version-deploy.yml - if: ${{ inputs.version != '' && inputs.environment != '' }} && + if: ${{ inputs.version != '' && inputs.environment != '' }} with: version: ${{ inputs.version }} environment: ${{ inputs.environment }} From 7151ae2de793d8d2cdaa0bd03e1b6885ced8a845 Mon Sep 17 00:00:00 2001 From: lukas Date: Wed, 30 Apr 2025 15:00:35 +0200 Subject: [PATCH 05/10] Add some changes --- .github/workflows/publish-new-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish-new-build.yml b/.github/workflows/publish-new-build.yml index eab92e4..c2e0607 100644 --- a/.github/workflows/publish-new-build.yml +++ b/.github/workflows/publish-new-build.yml @@ -107,7 +107,7 @@ jobs: - git-tag uses: ./.github/workflows/put-ssm-version-deploy.yml if: | - ${{ inputs.version != '' && inputs.deploy == true }} && + ${{ inputs.version != '' && inputs.deploy == true && inputs.environment != ''}} && always() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') From 77bb5093ff6bc1ac35073b5221057dec35f2191f Mon Sep 17 00:00:00 2001 From: lukas Date: Mon, 5 May 2025 09:45:20 +0200 Subject: [PATCH 06/10] Add environement for gettign secrets --- .github/workflows/put-ssm-version-deploy.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/put-ssm-version-deploy.yml b/.github/workflows/put-ssm-version-deploy.yml index ed07584..4643915 100644 --- a/.github/workflows/put-ssm-version-deploy.yml +++ b/.github/workflows/put-ssm-version-deploy.yml @@ -17,6 +17,7 @@ on: jobs: trigger-deploy: runs-on: ubuntu-latest + environment: "production-fidl" env: ECR_REPOSITORY: ${{ inputs.ecr-repository }} SSM_PARAMETER_NAME: "/${{ inputs.environment }}/${{ inputs.ecr-repository }}/version" From a4e911ecfe8557ddd2ae7b9cdef382f68429d81e Mon Sep 17 00:00:00 2001 From: lukas Date: Tue, 6 May 2025 13:40:46 +0200 Subject: [PATCH 07/10] Adjust new deploy to the new action --- .github/workflows/manually-trigger-deploy.yml | 20 +++--- .github/workflows/publish-new-build.yml | 25 ++++---- .github/workflows/put-ssm-version-deploy.yml | 50 --------------- ci/scripts/check-and-change-image.js | 63 ------------------- 4 files changed, 27 insertions(+), 131 deletions(-) delete mode 100644 .github/workflows/put-ssm-version-deploy.yml delete mode 100644 ci/scripts/check-and-change-image.js diff --git a/.github/workflows/manually-trigger-deploy.yml b/.github/workflows/manually-trigger-deploy.yml index f4b4eb1..c8bb27f 100644 --- a/.github/workflows/manually-trigger-deploy.yml +++ b/.github/workflows/manually-trigger-deploy.yml @@ -24,10 +24,16 @@ permissions: jobs: trigger-deploy: - uses: ./.github/workflows/put-ssm-version-deploy.yml - if: ${{ inputs.version != '' && inputs.environment != '' }} - with: - version: ${{ inputs.version }} - environment: ${{ inputs.environment }} - ecr-repository: filplus-backend - secrets: inherit + runs-on: ubuntu-latest + if: ${{ github.ref_name == 'main' && inputs.version != '' && inputs.deploy == true && inputs.environment != '' }} + steps: + - name: Trigger deploy + uses: neti-filplus-infra/filplus-deploy-action@main + with: + version: ${{ inputs.version }} + environment: ${{ inputs.environment }} + ecr-repository: filplus-backend + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_IMAGE_DEPLOYER }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_IMAGE_DEPLOYER }} + aws-region: us-east-1 + secrets-environment: production-fidl diff --git a/.github/workflows/publish-new-build.yml b/.github/workflows/publish-new-build.yml index c2e0607..9ef5f9c 100644 --- a/.github/workflows/publish-new-build.yml +++ b/.github/workflows/publish-new-build.yml @@ -101,18 +101,21 @@ jobs: git push origin $TAG_NAME trigger-deploy: + runs-on: ubuntu-latest needs: - code-check - bump-version + - build-and-publish - git-tag - uses: ./.github/workflows/put-ssm-version-deploy.yml - if: | - ${{ inputs.version != '' && inputs.deploy == true && inputs.environment != ''}} && - always() && - !contains(needs.*.result, 'failure') && - !contains(needs.*.result, 'cancelled') - with: - version: ${{ inputs.version }} - environment: ${{ inputs.environment }} - ecr-repository: filplus-backend - secrets: inherit + if: ${{ github.ref_name == 'main' && inputs.version != '' && inputs.deploy == true && inputs.environment != '' }} + steps: + - name: Trigger deploy + uses: neti-filplus-infra/filplus-deploy-action@main + with: + version: ${{ inputs.version }} + environment: ${{ inputs.environment }} + ecr-repository: filplus-backend + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_IMAGE_DEPLOYER }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_IMAGE_DEPLOYER }} + aws-region: us-east-1 + secrets-environment: production-fidl diff --git a/.github/workflows/put-ssm-version-deploy.yml b/.github/workflows/put-ssm-version-deploy.yml deleted file mode 100644 index 4643915..0000000 --- a/.github/workflows/put-ssm-version-deploy.yml +++ /dev/null @@ -1,50 +0,0 @@ -name: Put SSM version for deploy -run-name: "Put SSM version for ${{ github.ref_name }} triggered by ${{ github.actor }} for ${{ inputs.environment }}; version: ${{ inputs.version || 'N/A'}}" - -on: - workflow_call: - inputs: - version: - required: false - type: string - environment: - required: true - type: string - ecr-repository: - required: false - type: string - -jobs: - trigger-deploy: - runs-on: ubuntu-latest - environment: "production-fidl" - env: - ECR_REPOSITORY: ${{ inputs.ecr-repository }} - SSM_PARAMETER_NAME: "/${{ inputs.environment }}/${{ inputs.ecr-repository }}/version" - IMAGE_VERSION: "${{ inputs.version }}" - ENVIRONMENT: "${{ inputs.environment }}" - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Install Node.js - uses: actions/setup-node@v4 - with: - node-version: "20" - - - name: Configure AWS credentials - uses: aws-actions/configure-aws-credentials@v4 - with: - aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_IMAGE_DEPLOYER }} - aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_IMAGE_DEPLOYER }} - aws-region: us-east-1 - - - name: Login to Amazon ECR - uses: aws-actions/amazon-ecr-login@v2 - with: - mask-password: "true" - registry-type: public - - - name: Change ${{ env.ECR_REPOSITORY }} version to ${{ env.IMAGE_VERSION }} on ${{ inputs.environment }} in SSM parameter store - run: node ./ci/scripts/check-and-change-image.js diff --git a/ci/scripts/check-and-change-image.js b/ci/scripts/check-and-change-image.js deleted file mode 100644 index 56a00f4..0000000 --- a/ci/scripts/check-and-change-image.js +++ /dev/null @@ -1,63 +0,0 @@ -const { execSync } = require('child_process') - -const ECR_REPOSITORY = process.env.ECR_REPOSITORY -const IMAGE_VERSION = process.env.IMAGE_VERSION -const SSM_PARAMETER_NAME = process.env.SSM_PARAMETER_NAME -const ENVIRONMENT = process.env.ENVIRONMENT - -if (!ECR_REPOSITORY || !IMAGE_VERSION || !SSM_PARAMETER_NAME) { - console.error( - 'Missing environment variables: ECR_REPOSITORY, IMAGE_VERSION, SSM_PARAMETER_NAME', - ) - process.exit(1) -} - -function runCommand(command) { - try { - const output = execSync(command, { encoding: 'utf-8' }) - return JSON.parse(output) - } catch (error) { - console.error(`Error running command: ${command}`) - console.error(error.message) - } -} - -let currentVersions = runCommand( - `aws ssm get-parameter --name "${SSM_PARAMETER_NAME}" --query "Parameter.Value" --output json`, -) - -console.log('Current versions:', currentVersions) - -if (!currentVersions) { - console.error(`This app is not supported in this environment: ${ENVIRONMENT}`) - process.exit(1) -} - -console.log('Checking image in ECR...') - -const imageExist = runCommand( - `aws ecr-public describe-images --repository-name ${ECR_REPOSITORY} --region us-east-1 --image-ids imageTag=${IMAGE_VERSION}`, -) - -if (!imageExist || !imageExist.imageDetails) { - console.error(`Image ${IMAGE_VERSION} not found in ECR.`) - process.exit(1) -} - -console.log('Image was found in ECR:', imageExist) -console.log('Checking version in SSM...') - -const newCurrentSSMParam = IMAGE_VERSION - -console.log('New current SSM params:', newCurrentSSMParam) - -try { - const putNewVersion = `aws ssm put-parameter --name "${SSM_PARAMETER_NAME}" --value "${newCurrentSSMParam}" --type String --overwrite` - - execSync(putNewVersion, { stdio: 'inherit' }) - console.log(`Update version COMPLETE!`) - console.log(`Trigger the deployment process...`) -} catch (error) { - console.error(`Failed to put a new version:`, error.message) - process.exit(1) -} From dbfc1f22d7df6e4bc28e765a876e4b8c05e5252b Mon Sep 17 00:00:00 2001 From: lukas Date: Tue, 6 May 2025 13:55:08 +0200 Subject: [PATCH 08/10] Set environment to get secrets --- .github/workflows/manually-trigger-deploy.yml | 2 +- .github/workflows/publish-new-build.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/manually-trigger-deploy.yml b/.github/workflows/manually-trigger-deploy.yml index c8bb27f..630dd09 100644 --- a/.github/workflows/manually-trigger-deploy.yml +++ b/.github/workflows/manually-trigger-deploy.yml @@ -26,6 +26,7 @@ jobs: trigger-deploy: runs-on: ubuntu-latest if: ${{ github.ref_name == 'main' && inputs.version != '' && inputs.deploy == true && inputs.environment != '' }} + environment: production-fidl steps: - name: Trigger deploy uses: neti-filplus-infra/filplus-deploy-action@main @@ -36,4 +37,3 @@ jobs: aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_IMAGE_DEPLOYER }} aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_IMAGE_DEPLOYER }} aws-region: us-east-1 - secrets-environment: production-fidl diff --git a/.github/workflows/publish-new-build.yml b/.github/workflows/publish-new-build.yml index 9ef5f9c..a421909 100644 --- a/.github/workflows/publish-new-build.yml +++ b/.github/workflows/publish-new-build.yml @@ -108,6 +108,7 @@ jobs: - build-and-publish - git-tag if: ${{ github.ref_name == 'main' && inputs.version != '' && inputs.deploy == true && inputs.environment != '' }} + environment: production-fidl steps: - name: Trigger deploy uses: neti-filplus-infra/filplus-deploy-action@main @@ -118,4 +119,3 @@ jobs: aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_IMAGE_DEPLOYER }} aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_IMAGE_DEPLOYER }} aws-region: us-east-1 - secrets-environment: production-fidl From 37d733058b2904546af174ebc4a9ef4852b93e9d Mon Sep 17 00:00:00 2001 From: lukas Date: Wed, 7 May 2025 15:12:49 +0200 Subject: [PATCH 09/10] Disable to deploy on production from build image workflow --- .github/workflows/manually-trigger-deploy.yml | 21 ++++++++++++++--- .github/workflows/publish-new-build.yml | 23 +++++-------------- 2 files changed, 24 insertions(+), 20 deletions(-) diff --git a/.github/workflows/manually-trigger-deploy.yml b/.github/workflows/manually-trigger-deploy.yml index 630dd09..8b8e54d 100644 --- a/.github/workflows/manually-trigger-deploy.yml +++ b/.github/workflows/manually-trigger-deploy.yml @@ -23,12 +23,12 @@ permissions: contents: read jobs: - trigger-deploy: + trigger-staging-deploy: runs-on: ubuntu-latest - if: ${{ github.ref_name == 'main' && inputs.version != '' && inputs.deploy == true && inputs.environment != '' }} + if: ${{ inputs.version != '' && inputs.environment == 'staging' }} environment: production-fidl steps: - - name: Trigger deploy + - name: Trigger staging deploy uses: neti-filplus-infra/filplus-deploy-action@main with: version: ${{ inputs.version }} @@ -37,3 +37,18 @@ jobs: aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_IMAGE_DEPLOYER }} aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_IMAGE_DEPLOYER }} aws-region: us-east-1 + + trigger-production-deploy: + runs-on: ubuntu-latest + if: ${{ github.ref_name == 'main' && inputs.version != '' && inputs.environment == 'production' }} + environment: production-fidl + steps: + - name: Trigger production deploy + uses: neti-filplus-infra/filplus-deploy-action@main + with: + version: "${{ inputs.version }}-production-fidl" + environment: ${{ inputs.environment }} + ecr-repository: filplus-registry + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_IMAGE_DEPLOYER }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_IMAGE_DEPLOYER }} + aws-region: us-east-1 diff --git a/.github/workflows/publish-new-build.yml b/.github/workflows/publish-new-build.yml index a421909..d0e6225 100644 --- a/.github/workflows/publish-new-build.yml +++ b/.github/workflows/publish-new-build.yml @@ -13,20 +13,11 @@ on: description: "Enter the version number" required: true default: "latest" - deploy: - description: "Deploy the new version?" + deploy-to-staging: + description: "Deploy the new version on staging?" required: false type: boolean default: false - environment: - required: false - description: "Select the environment to deploy to" - type: choice - options: - - staging - # TODO: uncomment this when we want to deploy to production - # - production - default: staging jobs: code-check: @@ -100,21 +91,19 @@ jobs: git tag $TAG_NAME git push origin $TAG_NAME - trigger-deploy: + trigger-staging-deploy: runs-on: ubuntu-latest needs: - code-check - - bump-version - build-and-publish - - git-tag - if: ${{ github.ref_name == 'main' && inputs.version != '' && inputs.deploy == true && inputs.environment != '' }} + if: ${{ inputs.version != '' && inputs.deploy-to-staging == true }} environment: production-fidl steps: - - name: Trigger deploy + - name: Trigger staging deploy uses: neti-filplus-infra/filplus-deploy-action@main with: version: ${{ inputs.version }} - environment: ${{ inputs.environment }} + environment: staging ecr-repository: filplus-backend aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_IMAGE_DEPLOYER }} aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_IMAGE_DEPLOYER }} From cd0f32401a7d31645f80c56c42e9e0082d6e3384 Mon Sep 17 00:00:00 2001 From: lukas Date: Wed, 7 May 2025 15:13:43 +0200 Subject: [PATCH 10/10] Typo --- .github/workflows/manually-trigger-deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/manually-trigger-deploy.yml b/.github/workflows/manually-trigger-deploy.yml index 8b8e54d..8031989 100644 --- a/.github/workflows/manually-trigger-deploy.yml +++ b/.github/workflows/manually-trigger-deploy.yml @@ -46,7 +46,7 @@ jobs: - name: Trigger production deploy uses: neti-filplus-infra/filplus-deploy-action@main with: - version: "${{ inputs.version }}-production-fidl" + version: ${{ inputs.version }} environment: ${{ inputs.environment }} ecr-repository: filplus-registry aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_IMAGE_DEPLOYER }}