-
Notifications
You must be signed in to change notification settings - Fork 2
72 lines (63 loc) · 2.28 KB
/
publish-docker.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
name: Publish Docker Images
on:
push:
branches:
- main
tags:
- v*
jobs:
build-and-publish:
name: Build and publish Docker images to Docker Hub
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Login to GitHub Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and publish to registry
# every PR will trigger a push event on main, so check the push event is actually coming from main
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && github.repository == 'yadage/packtivity'
id: docker_build_latest
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile
tags: |
${{ github.repository }}:latest
ghcr.io/${{ github.repository }}:latest
labels: |
org.opencontainers.image.source=${{ github.event.repository.html_url }}
org.opencontainers.image.revision=${{ github.sha }}
push: true
platforms: linux/amd64,linux/arm64
- name: Build and publish to registry with release tag
if: github.event_name == 'release' && github.event.action == 'published' && github.repository == 'yadage/packtivity'
id: docker_build_release
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile
tags: |
${{ github.repository }}:latest
${{ github.repository }}:latest-stable
ghcr.io/${{ github.repository }}:latest
ghcr.io/${{ github.repository }}:latest-stable
labels: |
org.opencontainers.image.source=${{ github.event.repository.html_url }}
org.opencontainers.image.revision=${{ github.sha }}
push: true
platforms: linux/amd64,linux/arm64