-
Notifications
You must be signed in to change notification settings - Fork 25
43 lines (37 loc) · 1.29 KB
/
build_and_push_to_docker_hub.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: Build Docker image and push to Docker Hub
on:
release:
types: [ published ]
jobs:
build_and_push:
name: Build a new Docker image for the release (and a latest) and push it to Docker Hub
runs-on: ubuntu-latest
steps:
# https://github.com/actions/checkout
- uses: actions/checkout@v4
# https://github.com/docker/login-action
- name: Log into Docker Hub
if: github.event_name == 'release'
uses: docker/login-action@v3
with:
registry: docker.io
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
# https://github.com/docker/metadata-action
- name: Extract Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: signalen/backend
flavor: |
latest=${{ github.event_name == 'release' }} # generate 'latest' tag for releases
# https://github.com/docker/build-push-action
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@v5
with:
context: .
target: prod
push: ${{ github.event_name == 'release' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}