-
Notifications
You must be signed in to change notification settings - Fork 3
162 lines (142 loc) · 5.59 KB
/
stg-pipeline-testnet.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
name: Preview Testnet
on:
pull_request:
branches:
- develop
- release/*
types: [ opened, synchronize, closed ]
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
ENV: "stg"
APP: "aescan-testnet"
concurrency: aescan_staging_environment-${{ github.ref }}
jobs:
main:
runs-on: ubuntu-latest
name: build
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- name: Set up Docker Buildx
id: buildx
# Use the action from the master, as we've seen some inconsistencies with @v1
# Issue: https://github.com/docker/build-push-action/issues/286
uses: docker/setup-buildx-action@master
# Only worked for us with this option on
with:
install: true
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
# Key is named differently to avoid collision
key: ${{ runner.os }}-${{ env.ENV }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-${{ env.ENV }}-buildx
- name: Log in to dockerhub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_PASS }}
- name: Extract metadata for docker
if: github.event_name == 'pull_request' && github.event.action == 'opened' || github.event.action == 'synchronize'
id: meta
uses: docker/metadata-action@v3
with:
images: aeternity/aescan
tags: |
type=ref,event=pr
- name: Get commit sha on PR Sync
if: github.event_name == 'pull_request' && github.event.action == 'synchronize'
id: git-sha
shell: bash
run: |
echo GIT_SHA=$(git rev-parse --short HEAD) >> $GITHUB_OUTPUT
- name: Create dotenv
run: |
echo APP_VERSION=$(git describe --tags)-preview >> .env
- name: Build and push docker image
if: github.event_name == 'pull_request' && github.event.action == 'opened' || github.event.action == 'synchronize'
uses: docker/build-push-action@v2
with:
context: .
file: Dockerfile
push: true
build-args: BUILD_MODE=development
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-new
- name: Move cache
if: github.event_name == 'pull_request' && github.event.action == 'opened' || github.event.action == 'synchronize'
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
- uses: actions/checkout@v2
with:
repository: aeternity/gitops-apps-aelabs.git
ref: stg
token: ${{ secrets.BOT_GITHUB_TOKEN }}
persist-credentials: false
fetch-depth: 0
- name: Chekc the initial PR deployment status before make a PR Sync.
if: github.event_name == 'pull_request' && github.event.action == 'synchronize'
uses: aeternity/ae-github-actions/deploy-status@v7
with:
url: https://pr-${{ env.PR_NUMBER }}-${{ env.APP }}.${{ env.ENV }}.service.aepps.com
- name: Staging PR Sync
if: github.event_name == 'pull_request' && github.event.action == 'synchronize'
uses: aeternity/ae-github-actions/argocd-pr-sync@v5
with:
git-sha: ${{ steps.git-sha.outputs.GIT_SHA }}
url-prefix: pr-${{ env.PR_NUMBER }}
env: ${{ env.ENV }}
app: ${{ env.APP }}
- name: Staging deploy
if: github.event_name == 'pull_request' && github.event.action == 'opened'
uses: aeternity/ae-github-actions/argocd-deploy@v5
with:
url-prefix: pr-${{ env.PR_NUMBER }}
env: ${{ env.ENV }}
app: ${{ env.APP }}
- name: Staging undeploy
if: github.event_name == 'pull_request' && github.event.action == 'closed' && startsWith(github.head_ref, 'release') != true
uses: aeternity/ae-github-actions/argocd-undeploy@v5
with:
url-prefix: pr-${{ env.PR_NUMBER }}
env: ${{ env.ENV }}
app: ${{ env.APP }}
- name: Print PR url
uses: unsplash/comment-on-pr@v1.3.0
if: github.event_name == 'pull_request' && github.event.action == 'opened'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
msg: Deployed to https://pr-${{ env.PR_NUMBER }}-aescan.${{ env.ENV }}.service.aepps.com and https://pr-${{ env.PR_NUMBER }}-aescan-testnet.${{ env.ENV }}.service.aepps.com
check_for_duplicate_msg: true
- name: Push changes
uses: ad-m/github-push-action@master
with:
repository: aeternity/gitops-apps-aelabs
github_token: ${{ secrets.BOT_GITHUB_TOKEN }}
branch: stg
end-to-end-tests:
needs: main
runs-on: ubuntu-22.04
name: E2E Tests
timeout-minutes: 10
steps:
- name: Check the PR deployment status before run E2E tests.
uses: aeternity/ae-github-actions/deploy-status@v7.1.0
with:
url: https://pr-${{ env.PR_NUMBER }}-${{ env.APP }}.${{ env.ENV }}.service.aepps.com
timeout: 300
interval: 5
- name: Checkout
uses: actions/checkout@v4
- name: Cypress run
uses: cypress-io/github-action@v6
with:
config: baseUrl=https://pr-${{ env.PR_NUMBER }}-${{ env.APP }}.${{ env.ENV }}.service.aepps.com