Add deployment status
This commit is contained in:
parent
a2f7f42fdc
commit
89065cce41
2 changed files with 38 additions and 13 deletions
14
.github/workflows/test-env-cleanup.yml
vendored
14
.github/workflows/test-env-cleanup.yml
vendored
|
@ -1,4 +1,5 @@
|
||||||
name: TEST-ENV-CLEANUP
|
name: TEST-ENV-CLEANUP
|
||||||
|
# Remove test instance for closed pull requests
|
||||||
|
|
||||||
on:
|
on:
|
||||||
pull_request:
|
pull_request:
|
||||||
|
@ -11,8 +12,10 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
- uses: rlespinasse/github-slug-action@master
|
- uses: rlespinasse/github-slug-action@master
|
||||||
- name: Set domain
|
- name: Set domain
|
||||||
|
# Set test instance domain based on branch name slug
|
||||||
run: |
|
run: |
|
||||||
echo "::set-env name=domain::${{ env.GITHUB_HEAD_REF_SLUG }}.dashboard.saleor.rocks"
|
echo "::set-env name=domain::${{ env.GITHUB_HEAD_REF_SLUG }}.dashboard.saleor.rocks"
|
||||||
|
|
||||||
- name: Configure AWS credentials
|
- name: Configure AWS credentials
|
||||||
uses: aws-actions/configure-aws-credentials@v1
|
uses: aws-actions/configure-aws-credentials@v1
|
||||||
with:
|
with:
|
||||||
|
@ -21,7 +24,14 @@ jobs:
|
||||||
aws-region: ${{ secrets.AWS_DEFAULT_REGION }}
|
aws-region: ${{ secrets.AWS_DEFAULT_REGION }}
|
||||||
|
|
||||||
- name: Remove S3 directory
|
- name: Remove S3 directory
|
||||||
run: aws s3 rm s3://test-envs-stack-dashboards5d35b643-nempmfdd9fv/${{ env.domain }}
|
run: aws s3 rm s3://${{ secrets.AWS_TEST_DEPLOYMENT_BUCKET }}/${{ env.domain }}
|
||||||
|
|
||||||
- name: Invalidate cache
|
- name: Invalidate cache
|
||||||
run: aws cloudfront create-invalidation --distribution-id E1INMM566C4FJP --paths "/${{ env.domain }}/*"
|
run: aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_TEST_CF_DIST_ID }} --paths "/${{ env.domain }}/*"
|
||||||
|
|
||||||
|
- name: Mark deployment as deactivated
|
||||||
|
uses: bobheadxi/deployments@master
|
||||||
|
with:
|
||||||
|
step: deactivate-env
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
env: ${{ env.GITHUB_HEAD_REF_SLUG }}
|
||||||
|
|
37
.github/workflows/test-env-deploy.yml
vendored
37
.github/workflows/test-env-deploy.yml
vendored
|
@ -1,8 +1,9 @@
|
||||||
name: TEST-ENV-DEPLOYMENT
|
name: TEST-ENV-DEPLOYMENT
|
||||||
|
# Build and deploy test instance for every pull request
|
||||||
|
|
||||||
on:
|
on:
|
||||||
pull_request:
|
pull_request:
|
||||||
# we need to look for "edited" action because eg. API_URI can change in the PR description
|
# trigger on "edited" to update instance when configuration changes in PR description
|
||||||
types: [opened, reopened, edited, synchronize]
|
types: [opened, reopened, edited, synchronize]
|
||||||
branches: ["*"]
|
branches: ["*"]
|
||||||
|
|
||||||
|
@ -12,12 +13,22 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- uses: rlespinasse/github-slug-action@master
|
||||||
|
|
||||||
|
- name: Start deployment
|
||||||
|
uses: bobheadxi/deployments@master
|
||||||
|
id: deployment
|
||||||
|
with:
|
||||||
|
step: start
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
env: ${{ env.GITHUB_HEAD_REF_SLUG }}
|
||||||
|
ref: ${{ github.head_ref }}
|
||||||
|
|
||||||
- name: Cache node modules
|
- name: Cache node modules
|
||||||
uses: actions/cache@v2
|
uses: actions/cache@v2
|
||||||
env:
|
env:
|
||||||
cache-name: cache-node-modules
|
cache-name: cache-node-modules
|
||||||
with:
|
with:
|
||||||
# npm cache files are stored in `~/.npm` on Linux/macOS
|
|
||||||
path: ~/.npm
|
path: ~/.npm
|
||||||
key: ${{ runner.os }}-qa-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
|
key: ${{ runner.os }}-qa-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
|
||||||
restore-keys: |
|
restore-keys: |
|
||||||
|
@ -30,7 +41,7 @@ jobs:
|
||||||
npm ci
|
npm ci
|
||||||
|
|
||||||
- name: Set API URI
|
- name: Set API URI
|
||||||
# getting API_URI from PR description in case it has been changed
|
# Setting API_URI env variable from PR description
|
||||||
env:
|
env:
|
||||||
pull_request_body: ${{ github.event.pull_request.body }}
|
pull_request_body: ${{ github.event.pull_request.body }}
|
||||||
prefix: API_URI=
|
prefix: API_URI=
|
||||||
|
@ -45,14 +56,12 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
npm run build
|
npm run build
|
||||||
|
|
||||||
- uses: rlespinasse/github-slug-action@master
|
|
||||||
- name: Set domain
|
- name: Set domain
|
||||||
# generate normalized domain name, get rid of characters that may be found in branch names, but cannot be used in domain name like "/"
|
# Set test instance domain based on branch name slug
|
||||||
run: |
|
run: |
|
||||||
echo "::set-env name=domain::${{ env.GITHUB_HEAD_REF_SLUG }}.dashboard.saleor.rocks"
|
echo "::set-env name=domain::${{ env.GITHUB_HEAD_REF_SLUG }}.dashboard.saleor.rocks"
|
||||||
|
|
||||||
- name: Configure AWS credentials
|
- name: Configure AWS credentials
|
||||||
# get credentials for AWS from GitHub repo secrets
|
|
||||||
uses: aws-actions/configure-aws-credentials@v1
|
uses: aws-actions/configure-aws-credentials@v1
|
||||||
with:
|
with:
|
||||||
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||||
|
@ -60,11 +69,17 @@ jobs:
|
||||||
aws-region: ${{ secrets.AWS_DEFAULT_REGION }}
|
aws-region: ${{ secrets.AWS_DEFAULT_REGION }}
|
||||||
|
|
||||||
- name: Deploy to S3
|
- name: Deploy to S3
|
||||||
run: aws s3 sync ./build/dashboard s3://test-envs-stack-dashboards5d35b643-nempmfdd9fv/${{ env.domain }}
|
run: aws s3 sync ./build/dashboard s3://${{ secrets.AWS_TEST_DEPLOYMENT_BUCKET }}/${{ env.domain }}
|
||||||
|
|
||||||
- name: Invalidate cache
|
- name: Invalidate cache
|
||||||
run: aws cloudfront create-invalidation --distribution-id E1INMM566C4FJP --paths "/${{ env.domain }}/*"
|
run: aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_TEST_CF_DIST_ID }} --paths "/${{ env.domain }}/*"
|
||||||
|
|
||||||
- name: Print URL
|
- name: Update deployment status
|
||||||
run: |
|
uses: bobheadxi/deployments@master
|
||||||
echo https://${{ env.domain }}/
|
if: always()
|
||||||
|
with:
|
||||||
|
step: finish
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
status: ${{ job.status }}
|
||||||
|
env_url: https://${{ env.domain }}/
|
||||||
|
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
|
||||||
|
|
Loading…
Reference in a new issue