forked from saleor/saleor
-
Notifications
You must be signed in to change notification settings - Fork 0
66 lines (59 loc) · 2.42 KB
/
test-env-deploy.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
name: TEST-ENV-DEPLOYMENT
# Build and deploy test instance for every pull request
on:
pull_request:
types: [reopened, synchronize, labeled]
branches: ["**"]
jobs:
deploy:
name: Deploy test environment for labeled pull requests
if: ${{ ((github.event.action == 'labeled') && (github.event.label.name == 'test deployment')) || ((github.event.action != 'labeled') && contains(github.event.pull_request.labels.*.name, 'test deployment')) }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: rlespinasse/[email protected]
- name: Set domain
id: set-domain
# Set test instance domain based on branch name slug
run: |
echo "domain=${{ env.GITHUB_HEAD_REF_SLUG_URL }}.api.saleor.rocks" >> $GITHUB_OUTPUT
- name: Start deployment
uses: bobheadxi/[email protected]
id: deployment
with:
step: start
token: ${{ secrets.GITHUB_TOKEN }}
env: ${{ env.GITHUB_HEAD_REF_SLUG_URL }}
ref: ${{ github.head_ref }}
- name: Build and push
uses: kciter/aws-ecr-action@79255b7c5aa03dbf6d7c46cff2bfd049874cd98d # v4
with:
access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
account_id: ${{ secrets.AWS_ACCOUNT_ID }}
repo: saleor-testenvs
region: us-east-1
tags: ${{ env.GITHUB_HEAD_REF_SLUG_URL }},${{ github.sha }}
- name: Invoke deployment lambda
uses: gagoar/[email protected]
with:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
REGION: us-east-1
FunctionName: test-env-manager
Payload: >-
{
"action": "${{ github.event.action }}",
"label": "${{ env.GITHUB_HEAD_REF_SLUG_URL }}",
"image": "${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.us-east-1.amazonaws.com/saleor-testenvs:${{ github.sha }}"
}
LogType: Tail
- name: Update deployment status
uses: bobheadxi/[email protected]
if: always()
with:
step: finish
token: ${{ secrets.GITHUB_TOKEN }}
status: ${{ job.status }}
env_url: https://${{ steps.set-domain.outputs.domain }}/graphql/
deployment_id: ${{ steps.deployment.outputs.deployment_id }}