66 lines
2 KiB
YAML
66 lines
2 KiB
YAML
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 }}/
|