-
Notifications
You must be signed in to change notification settings - Fork 0
69 lines (54 loc) · 2.44 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
name: Push image to Docker hub and run e2e tests
on:
push:
branches:
- main
pull_request:
workflow_dispatch:
jobs:
push_to_registry:
name: Build & Push docker image to dockerhub
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Extract metadata to env variables
uses: HSLdevcom/jore4-tools/github-actions/extract-metadata@extract-metadata-v1
- name: Pull previous image to support caching
run: docker pull $IMAGE_NAME:builder || echo "Previous builder image not found"
- name: Build dependencies & source code into builder image to support caching
run: docker build --cache-from=$IMAGE_NAME:builder --target builder -t $IMAGE_NAME:builder .
- name: Build docker image for distribution
run: docker build --cache-from=$IMAGE_NAME:builder --cache-from=$IMAGE_NAME:latest -t $IMAGE_NAME:dev --build-arg NEXT_PUBLIC_GIT_HASH=$GITHUB_SHA .
- name: Tag docker image as 'latest'
if: ${{ github.ref == 'refs/heads/main' }}
run: docker tag $IMAGE_NAME:dev $IMAGE_NAME:latest
- name: Tag docker image as '<branch_name>-<git_commit_sha>'
run: docker tag $IMAGE_NAME:dev $IMAGE_NAME:$COMMIT_ID
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.JORE4_DOCKERHUB_USER }}
password: ${{ secrets.JORE4_DOCKERHUB_TOKEN }}
- name: Push image tagged with git commit details to Docker Hub
run: docker push $IMAGE_NAME:$COMMIT_ID
- name: Push rest of the tags to Docker Hub
if: ${{ github.ref == 'refs/heads/main' }}
run: |
docker push $IMAGE_NAME:builder
docker push $IMAGE_NAME:latest
run_e2e_tests:
needs: push_to_registry
name: Run e2e tests
runs-on: ubuntu-22.04
steps:
- name: Extract metadata to env variables
uses: HSLdevcom/jore4-tools/github-actions/extract-metadata@extract-metadata-v1
- name: start e2e env
uses: HSLdevcom/jore4-tools/github-actions/setup-e2e-environment@setup-e2e-environment-v1
with:
auth_version: "${{ env.IMAGE_NAME }}:${{ env.COMMIT_ID }}"
- name: Seed infrastructure links
uses: HSLdevcom/jore4-tools/github-actions/seed-infrastructure-links@seed-infrastructure-links-v1
- name: Run e2e tests
uses: HSLdevcom/jore4-tools/github-actions/run-cypress-tests@run-cypress-tests-v1