Skip to content

Commit

Permalink
Fix workflow deployment (#4604)
Browse files Browse the repository at this point in the history
* Fix PR workflow deployment

* Fix PR workflow deployment

* Fix PR workflow deployment
  • Loading branch information
andrzejewsky authored Jan 8, 2024
1 parent 97b05c9 commit 5725e72
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 10 deletions.
5 changes: 5 additions & 0 deletions .changeset/twelve-actors-flash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"saleor-dashboard": patch
---

Fix workflow deployments for PR automation
6 changes: 6 additions & 0 deletions .github/actions/prepare-api-variables/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ outputs:
API_URL:
description: "API url"
value: ${{ steps.generate.outputs.API_URL }}
BASE_URL_DOMAIN:
description: "Dashboard domain"
value: ${{ steps.generate.outputs.BASE_URL_DOMAIN }}
POOL_NAME:
description: "The name of the instance"
value: ${{ steps.generate.outputs.POOL_NAME }}
Expand All @@ -37,6 +40,7 @@ runs:
if [[ "$MODE" == 'pull-request' ]]; then
echo "BASE_URL=https://${PREFIX}${PULL_REQUEST_NUMBER}.dashboard.saleor.rocks" >> $GITHUB_OUTPUT
echo "API_URL=https://${PREFIX}${PULL_REQUEST_NUMBER}.staging.saleor.cloud/graphql/" >> $GITHUB_OUTPUT
echo "BASE_URL_DOMAIN=${PREFIX}${PULL_REQUEST_NUMBER}.dashboard.saleor.rocks" >> $GITHUB_OUTPUT
echo "POOL_NAME=${PREFIX}${PULL_REQUEST_NUMBER}" >> $GITHUB_OUTPUT
echo "POOL_INSTANCE=https://${PREFIX}${PULL_REQUEST_NUMBER}.staging.saleor.cloud" >> $GITHUB_OUTPUT
echo "BACKUP_NAMESPACE=snapshot-automation-tests" >> $GITHUB_OUTPUT
Expand All @@ -49,6 +53,7 @@ runs:
echo "BASE_URL=https://v${VERSION_SLUG}.staging.saleor.cloud/dashboard/" >> $GITHUB_OUTPUT
echo "API_URL=https://v${VERSION_SLUG}.staging.saleor.cloud/graphql/" >> $GITHUB_OUTPUT
echo "BASE_URL_DOMAIN=v${VERSION_SLUG}.staging.saleor.cloud" >> $GITHUB_OUTPUT
echo "POOL_NAME=${GITHUB_REF_SLUG} Staging" >> $GITHUB_OUTPUT
echo "POOL_INSTANCE=https://v${VERSION_SLUG}.staging.saleor.cloud/" >> $GITHUB_OUTPUT
echo "BACKUP_NAMESPACE=snapshot-automation-tests-${GITHUB_REF_SLUG}" >> $GITHUB_OUTPUT
Expand All @@ -59,6 +64,7 @@ runs:
if [[ "$MODE" == 'main' ]]; then
echo "BASE_URL=https://automation-dashboard.staging.saleor.cloud/dashboard/" >> $GITHUB_OUTPUT
echo "API_URL=https://automation-dashboard.staging.saleor.cloud/graphql/" >> $GITHUB_OUTPUT
echo "BASE_URL_DOMAIN=automation-dashboard.staging.saleor.cloud" >> $GITHUB_OUTPUT
echo "POOL_NAME=automation-dashboard" >> $GITHUB_OUTPUT
echo "POOL_INSTANCE=https://automation-dashboard.staging.saleor.cloud" >> $GITHUB_OUTPUT
echo "BACKUP_NAMESPACE=snapshot-automation-tests" >> $GITHUB_OUTPUT
Expand Down
3 changes: 3 additions & 0 deletions .github/actions/prepare-tests-variables/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ outputs:
BASE_URL:
description: "Dashboard base url"
value: ${{ steps.api.outputs.BASE_URL }}
BASE_URL_DOMAIN:
description: "Dashboard domain"
value: ${{ steps.api.outputs.BASE_URL_DOMAIN }}
API_URL:
description: "API url"
value: ${{ steps.api.outputs.API_URL }}
Expand Down
21 changes: 11 additions & 10 deletions .github/workflows/pr-automation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ jobs:
POOL_NAME: ${{ steps.cloud_variables.outputs.POOL_NAME }}
POOL_INSTANCE: ${{ steps.cloud_variables.outputs.POOL_INSTANCE }}
BASE_URL: ${{ steps.cloud_variables.outputs.BASE_URL }}
BASE_URL_DOMAIN: ${{ steps.cloud_variables.outputs.BASE_URL_DOMAIN }}
API_URL: ${{ steps.cloud_variables.outputs.API_URL }}
BACKUP_ID: ${{ steps.cloud_variables.outputs.BACKUP_ID }}
BACKUP_VER: ${{ steps.cloud_variables.outputs.BACKUP_VER }}
Expand Down Expand Up @@ -97,14 +98,14 @@ jobs:
- name: Deploy to S3
env:
AWS_TEST_DEPLOYMENT_BUCKET: ${{ secrets.AWS_TEST_DEPLOYMENT_BUCKET }}
BASE_URL: ${{ needs.initialize-cloud.outputs.BASE_URL }}
run: aws s3 sync ./build/dashboard "s3://${AWS_TEST_DEPLOYMENT_BUCKET}/${BASE_URL}"
BASE_URL_DOMAIN: ${{ needs.initialize-cloud.outputs.BASE_URL_DOMAIN }}
run: aws s3 sync ./build/dashboard "s3://${AWS_TEST_DEPLOYMENT_BUCKET}/${BASE_URL_DOMAIN}"

- name: Invalidate cache
env:
AWS_TEST_CF_DIST_ID: ${{ secrets.AWS_TEST_CF_DIST_ID }}
BASE_URL: ${{ needs.initialize-cloud.outputs.BASE_URL }}
run: aws cloudfront create-invalidation --distribution-id "$AWS_TEST_CF_DIST_ID" --paths "/${BASE_URL}/*"
BASE_URL_DOMAIN: ${{ needs.initialize-cloud.outputs.BASE_URL_DOMAIN }}
run: aws cloudfront create-invalidation --distribution-id "$AWS_TEST_CF_DIST_ID" --paths "/${BASE_URL_DOMAIN}/*"

- name: Update deployment status
uses: bobheadxi/deployments@88ce5600046c82542f8246ac287d0a53c461bca3
Expand All @@ -113,7 +114,7 @@ jobs:
step: finish
token: ${{ secrets.GITHUB_TOKEN }}
status: ${{ job.status }}
env_url: https://${{ needs.initialize-cloud.outputs.BASE_URL }}
env_url: ${{ needs.initialize-cloud.outputs.BASE_URL }}
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
env: ${{ needs.initialize-cloud.outputs.POOL_NAME }}

Expand Down Expand Up @@ -168,14 +169,14 @@ jobs:
- name: Deploy to S3
env:
AWS_TEST_DEPLOYMENT_BUCKET: ${{ secrets.AWS_TEST_DEPLOYMENT_BUCKET }}
BASE_URL: ${{ needs.initialize-cloud.outputs.BASE_URL }}
run: aws s3 sync ./build/storybook "s3://${AWS_TEST_DEPLOYMENT_BUCKET}/${BASE_URL}/storybook"
BASE_URL_DOMAIN: ${{ needs.initialize-cloud.outputs.BASE_URL_DOMAIN }}
run: aws s3 sync ./build/storybook "s3://${AWS_TEST_DEPLOYMENT_BUCKET}/${BASE_URL_DOMAIN}/storybook"

- name: Invalidate cache
env:
AWS_TEST_CF_DIST_ID: ${{ secrets.AWS_TEST_CF_DIST_ID }}
BASE_URL: ${{ needs.initialize-cloud.outputs.BASE_URL }}
run: aws cloudfront create-invalidation --distribution-id "$AWS_TEST_CF_DIST_ID" --paths "/${BASE_URL}/*"
BASE_URL_DOMAIN: ${{ needs.initialize-cloud.outputs.BASE_URL_DOMAIN }}
run: aws cloudfront create-invalidation --distribution-id "$AWS_TEST_CF_DIST_ID" --paths "/${BASE_URL_DOMAIN}/*"

- name: Update storybook deployment status
uses: bobheadxi/deployments@88ce5600046c82542f8246ac287d0a53c461bca3
Expand All @@ -184,7 +185,7 @@ jobs:
step: finish
token: ${{ secrets.GITHUB_TOKEN }}
status: ${{ job.status }}
env_url: https://${{ needs.initialize-cloud.outputs.BASE_URL }}/storybook/index.html
env_url: ${{ needs.initialize-cloud.outputs.BASE_URL }}/storybook/index.html
deployment_id: ${{ steps.storybook-deployment.outputs.deployment_id }}
env: storybook ${{ needs.initialize-cloud.outputs.POOL_NAME }}

Expand Down

0 comments on commit 5725e72

Please sign in to comment.