generated from hmcts/expressjs-template
-
Notifications
You must be signed in to change notification settings - Fork 1
81 lines (66 loc) · 2.35 KB
/
cd.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
on:
pull_request:
branches:
- master
push:
branches:
- master
name: Publish
env:
REPO_NAME: 'rpe/response-frontend'
jobs:
build:
runs-on: ubuntu-20.04
env:
CI: true
steps:
- uses: actions/checkout@v3
- name: use node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
registry-url: https://registry.npmjs.org/ # Needed for auth
cache: 'yarn'
- name: yarn install
run: yarn install --frozen-lockfile
- name: lint
run: yarn lint
- name: build
run: yarn build
- name: test
run: yarn test
- name: test:routes
run: yarn test:routes
- name: a11y
run: yarn test:a11y
deploy:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v3
- name: "Get Short Sha Hash"
id: get-short-sha
uses: actions/[email protected]
with:
script: |
const shortSha = context.sha.substring(0, 7)
core.setOutput('shortSha', shortSha)
- name: 'Get Commit Timestamp'
id: get-timestamp
run: |
TIMESTAMP=$(git log -1 --format='%cI' | sed -e's/[-T:]//g' -e's/+.*$//g')
echo "::set-output name=timestamp::$TIMESTAMP"
- name: 'Build and push image'
uses: azure/docker-login@v1
with:
login-server: ${{ secrets.REGISTRY_LOGIN_SERVER }}
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- run: |
docker build . -t ${{ secrets.REGISTRY_LOGIN_SERVER }}/${{ env.REPO_NAME }}:pr-${{github.event.number}}-${{ steps.get-short-sha.outputs.shortSha }}
docker push ${{ secrets.REGISTRY_LOGIN_SERVER }}/${{ env.REPO_NAME }}:pr-${{github.event.number}}-${{ steps.get-short-sha.outputs.shortSha }}
if: startsWith(github.ref, 'refs/pull')
- run: |
docker build . -t ${{ secrets.REGISTRY_LOGIN_SERVER }}/${{ env.REPO_NAME }}:prod-${{ steps.get-short-sha.outputs.shortSha }}-${{ steps.get-timestamp.outputs.timestamp }}
docker push ${{ secrets.REGISTRY_LOGIN_SERVER }}/${{ env.REPO_NAME }}:prod-${{ steps.get-short-sha.outputs.shortSha }}-${{ steps.get-timestamp.outputs.timestamp }}
if: github.ref == 'refs/heads/master'