-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: improve deployment actions (#708)
* fix: improve the deployment workflow by using shared workflow and environments - allows us to have one logic that can be used by both production/staging - added a slack notification action and message creation script * fix: add tier1 list and support for deploying to just tier-1 * fix: use new deployment format
- Loading branch information
Showing
16 changed files
with
199 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
name: Deploy to Production - Tier 1 Only | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
workflow_dispatch: | ||
|
||
jobs: | ||
test: | ||
uses: ./.github/workflows/deploy.yml | ||
with: | ||
environment: production | ||
store_list: ./deployment/production-tier1.json | ||
secrets: inherit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
name: Deploy to Production - All Stores | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
workflow_dispatch: | ||
|
||
jobs: | ||
test: | ||
uses: ./.github/workflows/deploy.yml | ||
with: | ||
environment: production | ||
secrets: inherit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
name: Deploy to Staging | ||
|
||
on: | ||
push: | ||
branches: | ||
- staging | ||
workflow_dispatch: | ||
|
||
jobs: | ||
test: | ||
uses: ./.github/workflows/deploy.yml | ||
with: | ||
environment: staging | ||
secrets: inherit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
name: Storefront deployment | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
environment: | ||
required: true | ||
type: string | ||
store_list: | ||
required: false | ||
type: string | ||
secrets: | ||
ENV: | ||
required: true | ||
AWS_ACCESS_KEY_ID: | ||
required: true | ||
AWS_SECRET_ACCESS_KEY: | ||
required: true | ||
API_HOST: | ||
required: true | ||
API_CREDENTIAL: | ||
required: true | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
environment: ${{ inputs.environment }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Setup NodeJS & Yarn | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18 | ||
cache: yarn | ||
|
||
- name: Install dependencies | ||
run: yarn install | ||
|
||
- name: Setup secrets | ||
run: base64 -d <<<${{ secrets.ENV }} > apps/storefront/.env.${{ inputs.environment }} | ||
|
||
- name: Build | ||
run: yarn build:${{ inputs.environment }} | ||
|
||
- name: Calculate revision | ||
run: echo "GITHUB_SHA_SHORT=$(echo $GITHUB_SHA | cut -c 1-6)" >> $GITHUB_ENV | ||
|
||
- name: Configure AWS credentials | ||
uses: aws-actions/configure-aws-credentials@v1 | ||
with: | ||
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
aws-region: us-west-2 | ||
|
||
- name: Push files to s3 | ||
run: | | ||
aws s3 cp apps/storefront/dist s3://b3-cdn-files/b2b/${{ inputs.environment }}/storefront --recursive --acl public-read | ||
aws cloudfront create-invalidation --distribution-id E1ZCC8QPXD9I6K --path "/*" | ||
- name: Create storefront revision | ||
shell: bash | ||
run: | | ||
poly_js=$(find apps/storefront/dist -name polyfills-legacy.*.js -type f -printf '%f') | ||
index_js=$(find apps/storefront/dist -name index.*.js ! -path "apps/storefront/dist/assets/*" -type f -printf '%f') | ||
indexLegacy_js=$(find apps/storefront/dist -name index-legacy.*.js ! -path "apps/storefront/dist/assets/*" -type f -printf '%f') | ||
curl --location --request POST '${{ secrets.API_HOST }}/api/v3/stores/revisions' \ | ||
--header 'Authorization: Basic ${{ secrets.API_CREDENTIAL }}' \ | ||
--header 'Content-Type: application/json' \ | ||
--data-binary @- << EOF | ||
{ | ||
"jsFiles": [ | ||
"<script type=\"module\" crossorigin src=\"https://cdn.bundleb2b.net/b2b/${{ inputs.environment }}/storefront/${index_js}\"></script>", | ||
"<script nomodule crossorigin src=\"https://cdn.bundleb2b.net/b2b/${{ inputs.environment }}/storefront/${poly_js}\"></script>", | ||
"<script nomodule crossorigin src=\"https://cdn.bundleb2b.net/b2b/${{ inputs.environment }}/storefront/${indexLegacy_js}\"></script>" | ||
], | ||
"revisionTitle": "${GITHUB_SHA_SHORT}" | ||
} | ||
EOF | ||
- name: Deploy storefront revision to specific stores | ||
if: ${{ inputs.store_list != '' }} | ||
shell: bash | ||
run: | | ||
curl --location --request POST '${{ secrets.API_HOST }}/api/v3/stores/deployments' \ | ||
--header 'Authorization: Basic ${{ secrets.API_CREDENTIAL }}' \ | ||
--header 'Content-Type: application/json' \ | ||
--data-binary @- << EOF | ||
{ | ||
"deploy_all": false, | ||
"store_hashes": $(cat ${{ inputs.store_list }}), | ||
"revision": "${GITHUB_SHA_SHORT}" | ||
} | ||
EOF | ||
- name: Deploy storefront revision to all stores | ||
if: ${{ inputs.store_list == '' }} | ||
shell: bash | ||
run: | | ||
curl --location --request POST '${{ secrets.API_HOST }}/api/v3/stores/deployments' \ | ||
--header 'Authorization: Basic ${{ secrets.API_CREDENTIAL }}' \ | ||
--header 'Content-Type: application/json' \ | ||
--data-binary @- << EOF | ||
{ | ||
"deploy_all": true, | ||
"revision": "${GITHUB_SHA_SHORT}" | ||
} | ||
EOF | ||
- name: Send deployment stable message | ||
uses: slackapi/slack-github-action@v1 | ||
if: ${{ inputs.environment == 'production' }} | ||
with: | ||
payload: | | ||
{ | ||
"channel": "b2b-deployments", | ||
"text": "B2B Storefront Deployed\nEnvironment: `${{ inputs.environment }}`\nRevision: `${{ github.sha }}`\nBuild: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" | ||
} | ||
env: | ||
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} | ||
- name: Send deployment failed message | ||
if: ${{ inputs.environment == 'production' }} && failure() | ||
uses: slackapi/slack-github-action@v1 | ||
with: | ||
payload: | | ||
{ | ||
"channel": "b2b-deployments", | ||
"text": "B2B Storefront Deployment Failed\nEnvironment: `${{ inputs.environment }}`\nRevision: `${{ github.sha }}`\nBuild: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" | ||
} | ||
env: | ||
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,3 +33,5 @@ yarn-error.log* | |
|
||
# ide | ||
.vscode | ||
|
||
slack-message.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
apps/storefront/src/pages/orderDetail/components/CreateShoppingList.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[ | ||
"nphozlrwue", | ||
"p70ju3hpl0", | ||
"sh1inxgzt3", | ||
"oov9d9k3v8", | ||
"p1xpzyx4re", | ||
"c75o808cpx" | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters