-
Notifications
You must be signed in to change notification settings - Fork 11
59 lines (52 loc) · 1.98 KB
/
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
name: Build and push docker image for branch or tag
on:
release:
types: [ released ]
push:
branches: [ '**' ]
jobs:
build-brandr-api-container:
name: Build brandr-api container
runs-on: ubuntu-latest
if: github.repository == 'ScientaNL/brandr-api'
steps:
- name: Cancel Previous Runs
uses: styfle/[email protected]
with:
access_token: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout repository
uses: actions/checkout@v4
- name: Set Github environment variables
uses: ScientaNL/[email protected]
- name: DockerHub Login
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_PUBLIC_USERNAME }}
password: ${{ secrets.DOCKERHUB_PUBLIC_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build & push Docker image for branch
uses: docker/build-push-action@v5
with:
file: ./docker/Dockerfile
context: .
build-args: |
- API_VERSION=${{env.GITHUB_REF_NAME_SLUG}}-${{env.GITHUB_SHA_SHORT}}
push: true
tags: scienta/brandr-api:branch-${{env.GITHUB_REF_NAME_SLUG}}
cache-from: |
type=registry,ref=scienta/brandr-api:cache-branch-${{env.GITHUB_REF_NAME_SLUG}}
type=registry,ref=scienta/brandr-api:cache-branch-master
cache-to: type=registry,ref=scienta/brandr-api:cache-branch-${{env.GITHUB_REF_NAME_SLUG}}
- name: Build & push Docker image for release
if: github.event_name == 'release'
uses: docker/build-push-action@v2
with:
file: ./docker/Dockerfile
context: .
push: true
tags: scienta/brandr-api:${{env.GITHUB_REF_NAME_SLUG}}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
build-args: |
- API_VERSION=${{env.GITHUB_REF_NAME_SLUG}}