-
Notifications
You must be signed in to change notification settings - Fork 25
107 lines (93 loc) · 3.75 KB
/
test-and-build.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
# (Copied from IcaliaLabs/portal)
on:
workflow_call:
outputs:
git-commit-short-sha:
description: "The Git commit short SHA"
value: ${{ jobs.test-and-build.outputs.git-commit-short-sha }}
container-image-digest:
description: "The Docker image digest which uniquely identifies the built image"
value: ${{ jobs.test-and-build.outputs.container-image-digest }}
# On this project, was some changes to the original workflow, since we are hosting this
# project on Azure Web Apps, we don't need to deploy to Google Cloud Run, so we removed
# the deploy-to-staging and deploy-to-production jobs.
# Instead to deploy, we're just building the image and running the tests. The image will be
# pushed to the Dockerhub, because it's free and we don't need to pay for it.
jobs:
test-and-build:
name: Test and Build
runs-on: ubuntu-latest
outputs:
git-commit-short-sha: ${{ steps.variables.outputs.git-commit-short-sha }}
container-image-digest: ${{ steps.build-and-push-release-image.outputs.digest }}
steps:
- name: Checkout the code
uses: actions/[email protected]
- # We'll generate a unique id that we'll use to identify the build run
# on our systems
name: Generate UUID for build
id: uuidgen
run: echo "::set-output name=uuid::$(uuidgen)"
- name: Set additional variables
id: variables
uses: icalia-actions/[email protected]
- name: Set build timestamp
id: set-build-timestamp
run: echo "::set-output name=timestamp::$(date +%s)"
- name: Set up Docker Buildx
id: buildx
uses: docker/[email protected]
with:
version: v0.9.1
- name: Build Test Image
id: build-test-image
uses: docker/[email protected]
with:
load: true
target: testing
platforms: linux/amd64
builder: ${{ steps.buildx.outputs.name }}
build-args: |
DEVELOPER_UID=${{ steps.variables.outputs.runner-uid }}
DEVELOPER_USERNAME=${{ steps.variables.outputs.runner-user }}
tags: |
icalialabs/sepomex-web:testing-${{ steps.variables.outputs.git-dasherized-branch }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Run tests
env:
UID: ${{ steps.variables.outputs.runner-uid }}
USER: ${{ steps.variables.outputs.runner-user }}
TESTING_IMAGE_TAG: ":testing-${{ steps.variables.outputs.git-dasherized-branch }}"
run: docker compose run --rm tests
- name: Archive system spec screenshots
uses: actions/[email protected]
if: always()
with:
name: system-spec-screenshots
retention-days: 7
path: |
tmp/capybara/screenshots
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build & Push Release Image
id: build-and-push-release-image
uses: docker/build-push-action@v5
with:
push: true
target: release
platforms: linux/amd64
builder: ${{ steps.buildx.outputs.name }}
build-args: |
DEVELOPER_UID=${{ steps.variables.outputs.runner-uid }}
DEVELOPER_USERNAME=${{ steps.variables.outputs.runner-user }}
DEPLOY_NAME=production
tags: |
icalia/sepomex:${{ steps.variables.outputs.git-commit-short-sha }}
icalia/sepomex:${{ steps.variables.outputs.git-dasherized-branch }}
icalia/sepomex:latest
cache-from: type=gha
cache-to: type=gha,mode=max