-
Notifications
You must be signed in to change notification settings - Fork 3
79 lines (67 loc) · 2.38 KB
/
docker-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
name: Docker
on:
push:
branches: [ '**' ]
tags: [ 'v*.*.*' ]
pull_request:
branches: [ '**' ]
env:
# github.repository as <account>/<repo>
IMAGE_NAME: mnestix-browser
IMAGE_TAG: latest
# Update the version manually
IMAGE_TAG_VERSION: 1.3.2
REGISTRY_USER: ${{ secrets.DOCKER_USERNAME }}
REGISTRY_PASS: ${{ secrets.DOCKER_API_TOKEN }}
jobs:
default:
name: build, test and push image
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Extract branch name
id: extract_branch
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
- name: Checkout repository
uses: actions/checkout@v4
# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into docker hub
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
username: ${{ env.REGISTRY_USER }}
password: ${{ env.REGISTRY_PASS }}
- name: Test units
id: test_units
run: yarn install && npx jest
- name: Build image
id: build
run: docker compose build mnestix-browser
- name: E2E test
id: test
run: docker compose -f compose.yml -f docker-compose/compose.test.yml --profile tests up -d &&
docker compose -f compose.yml -f docker-compose/compose.test.yml attach cypress-test
- name: E2E test collect artifact
id: test_artifact
if: always()
uses: actions/upload-artifact@master
with:
name: cypress-artifacts
path: cypress-artifacts/
- name: Push Image to Production
id: push-prod
if: github.ref == 'refs/heads/main'
run: docker tag mnestix/$IMAGE_NAME mnestix/$IMAGE_NAME:$IMAGE_TAG &&
docker tag mnestix/$IMAGE_NAME mnestix/$IMAGE_NAME:$IMAGE_TAG_VERSION &&
docker push mnestix/$IMAGE_NAME:$IMAGE_TAG &&
docker push mnestix/$IMAGE_NAME:$IMAGE_TAG_VERSION
- name: Push Image to development
id: push-dev
if: github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/staging'
env:
BRANCH_NAME: ${{ steps.extract_branch.outputs.branch }}
run: docker tag mnestix/$IMAGE_NAME mnestix/$IMAGE_NAME:$BRANCH_NAME &&
docker push mnestix/$IMAGE_NAME:$BRANCH_NAME