-
Notifications
You must be signed in to change notification settings - Fork 0
43 lines (39 loc) · 1.36 KB
/
docker-image.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
name: Docker Image CI
on:
push:
branches:
- 'main'
pull_request:
branches:
- 'main'
env:
TEST_CONTAINER_TAG: "ghcr.io/${{github.repository}}:${{github.sha}}"
RELEASE_CONTAINER_TAG: "ghcr.io/${{github.repository}}:latest"
jobs:
build_test:
name: Build Test Container
runs-on: ubuntu-latest
steps:
- name: Login to Registry
run: >-
echo "${{ secrets.GITHUB_TOKEN }}"
| docker login ghcr.io -u $ --password-stdin
- name: Checkout
uses: actions/checkout@v4
- name: Build Test Container
# in bash, `${ENVIRONMENT_VARIABLE,,}` lowercases whatever is stored in `ENVIRONMENT_VARIABLE`
run: >-
docker build
--pull
--build-arg CORES="$(nproc)"
--tag "${TEST_CONTAINER_TAG,,}"
${{github.workspace}}
- name: Push Test Container
run: >-
docker push "${TEST_CONTAINER_TAG,,}"
- name: Push Latest Tag
if: ${{github.ref_name == 'main'}}
run: |
docker pull "${TEST_CONTAINER_TAG,,}"
docker tag "${TEST_CONTAINER_TAG,,}" "${RELEASE_CONTAINER_TAG,,}"
docker push "${RELEASE_CONTAINER_TAG,,}"