Setup test environment deployment workflow
This commit is contained in:
parent
9a7c8553e5
commit
9c47b04341
2 changed files with 72 additions and 0 deletions
6
.github/PULL_REQUEST_TEMPLATE.md
vendored
6
.github/PULL_REQUEST_TEMPLATE.md
vendored
|
@ -20,3 +20,9 @@ greatly reduce the amount of work needed to review your work. -->
|
|||
1. [ ] The changes are tested.
|
||||
1. [ ] Type definitions are up to date.
|
||||
1. [ ] Changes are mentioned in the changelog.
|
||||
|
||||
### Test environment config
|
||||
|
||||
```
|
||||
API_URI=https://master.staging.saleor.rocks/graphql/
|
||||
```
|
||||
|
|
66
.github/workflows/test-env-deploy.yml
vendored
Normal file
66
.github/workflows/test-env-deploy.yml
vendored
Normal file
|
@ -0,0 +1,66 @@
|
|||
name: TEST-ENV-DEPLOYMENT
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types: [opened, reopened, edited, synchronize]
|
||||
branches: ["*"]
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Cache node modules
|
||||
uses: actions/cache@v2
|
||||
env:
|
||||
cache-name: cache-node-modules
|
||||
with:
|
||||
# npm cache files are stored in `~/.npm` on Linux/macOS
|
||||
path: ~/.npm
|
||||
key: ${{ runner.os }}-qa-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-qa-${{ env.cache-name }}-
|
||||
${{ runner.os }}-qa-
|
||||
${{ runner.os }}-
|
||||
|
||||
- name: Install deps
|
||||
run: |
|
||||
npm ci
|
||||
|
||||
- name: Set API URI
|
||||
env:
|
||||
pull_request_body: ${{ github.event.pull_request.body }}
|
||||
prefix: API_URI=
|
||||
pattern: (http|https)://[a-zA-Z0-9.]+/graphql/?
|
||||
run: |
|
||||
echo "::set-env name=API_URI::$(echo $pull_request_body | grep -Eo "$prefix$pattern" | sed s/$prefix// | head -n 1)"
|
||||
|
||||
- name: Run build
|
||||
env:
|
||||
APP_MOUNT_URI: /
|
||||
STATIC_URL: /
|
||||
run: |
|
||||
npm run build
|
||||
|
||||
- uses: rlespinasse/github-slug-action@master
|
||||
- name: Set domain
|
||||
run: |
|
||||
echo "::set-env name=domain::${{ env.GITHUB_HEAD_REF_SLUG }}.dashboard.saleor.rocks"
|
||||
|
||||
- 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: ${{ secrets.AWS_DEFAULT_REGION }}
|
||||
|
||||
- name: Deploy to S3
|
||||
run: aws s3 sync ./build/dashboard s3://test-envs-stack-dashboards5d35b643-nempmfdd9fv/${{ env.domain }}
|
||||
|
||||
- name: Invalidate cache
|
||||
run: aws cloudfront create-invalidation --distribution-id E1INMM566C4FJP --paths "/${{ env.domain }}/*"
|
||||
|
||||
- name: Print URL
|
||||
run: |
|
||||
echo https://${{ env.domain }}/
|
Loading…
Reference in a new issue