-
Notifications
You must be signed in to change notification settings - Fork 55
49 lines (44 loc) · 1.49 KB
/
build-and-push-docker.yaml
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
name: Build and Push accweb Docker Image
on:
push:
tags:
- '*'
jobs:
build-docker-accweb:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout and setup
uses: actions/checkout@v2
- name: Get the version
id: get_version
run: echo "VERSION=${GITHUB_REF/refs\/tags\//}" >> "$GITHUB_OUTPUT"
- name: Get the commit
id: get_commit
run: echo "COMMIT=${GITHUB_SHA}" >> "$GITHUB_OUTPUT"
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
# list of Docker images to use as base name for tags
images: accweb/accweb
# generate Docker tags based on the following events/attributes
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v5
with:
push: true
build-args: |
VERSION=${{ steps.get_version.outputs.VERSION }}
COMMIT=${{ steps.get_version.outputs.COMMIT }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}