-
Notifications
You must be signed in to change notification settings - Fork 0
88 lines (81 loc) · 2.76 KB
/
pr_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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
name: Deploy PR
on:
issue_comment:
types:
- created
- edited
pull_request:
types:
- opened
- synchronize
defaults:
run:
shell: bash -exuo pipefail {0}
concurrency:
group: deployment
cancel-in-progress: false
jobs:
get-ref:
name: Get ref
runs-on: ubuntu-22.04
outputs:
ref: ${{ steps.get-ref-from-pr.outputs.ref || steps.get-ref-from-issue.outputs.ref }}
sha: ${{ steps.get-ref-from-pr.outputs.sha || steps.get-ref-from-issue.outputs.sha }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v3
- id: get-ref-from-pr
name: Get ref from PR
if: github.event_name == 'pull_request'
run: |
echo "ref=${{ github.event.pull_request.head.ref }}" >> "$GITHUB_OUTPUT"
echo "sha=${{ github.event.pull_request.head.sha }}" >> "$GITHUB_OUTPUT"
- id: get-ref-from-issue
name: Get ref from issue
if: github.event_name == 'issue_comment' && github.event.issue.pull_request && github.event.comment.body == '/deploy'
run: |
echo "ref=$(gh pr view ${{ github.event.issue.number }} --json headRefName | jq -r .headRefName)" >> "$GITHUB_OUTPUT"
echo "sha=$(gh pr view ${{ github.event.issue.number }} --json headRefOid | jq -r .headRefOid)" >> "$GITHUB_OUTPUT"
deploy:
name: Deploy
needs: get-ref
uses: arikkfir/delivery/.github/workflows/deploy-to-environment.yml@main
if: needs.get-ref.outputs.ref && needs.get-ref.outputs.sha
with:
branch: ${{ needs.get-ref.outputs.ref }}
images: |-
ghcr.io/${{ github.repository }}/backend: ${{ needs.get-ref.outputs.sha }}
ghcr.io/${{ github.repository }}/frontend: ${{ needs.get-ref.outputs.sha }}
ghcr.io/${{ github.repository }}/migrations: ${{ needs.get-ref.outputs.sha }}
ghcr.io/${{ github.repository }}/neo4j: ${{ needs.get-ref.outputs.sha }}
secrets: inherit
e2e-tests:
name: End-to-end Tests
needs: [ get-ref, deploy ]
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: arikkfir/delivery-env-name@v1
id: env
with:
branch: ${{ needs.get-ref.outputs.ref }}
- uses: actions/setup-node@v3
with:
node-version: 20.x
cache: npm
cache-dependency-path: e2e/package-lock.json
- run: npm ci
working-directory: e2e
- run: npx playwright install --with-deps
working-directory: e2e
- run: npx playwright test
env:
ENV_NAME: ${{ steps.env.outputs.name }}
working-directory: e2e
- uses: actions/upload-artifact@v3
if: always()
with:
name: playwright-report
path: e2e/test-results/
retention-days: 30