forked from Lurkars/gloomhavensecretariat
-
Notifications
You must be signed in to change notification settings - Fork 0
66 lines (63 loc) · 2.11 KB
/
publish-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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
name: "Publish Docker Image"
on:
workflow_dispatch:
push:
tags:
- "v*"
- "!v*-*"
env:
SLUG_DOCKERHUB: ${{ secrets.DOCKER_USERNAME }}/ghs
SLUG_GHCR: ${{ github.repository_owner }}/ghs
jobs:
build-and-publish-docker-image:
name: Build and Publish Docker Image
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
-
name: Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ env.SLUG_DOCKERHUB }}
ghcr.io/${{ env.SLUG_GHCR }}
-
name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
-
name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }} # automatic: https://docs.github.com/en/actions/security-guides/automatic-token-authentication
-
name: Build and push
uses: docker/build-push-action@v5
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
-
name: Inspect Image published to Docker
run: |
docker pull "${{ env.SLUG_DOCKERHUB }}:${{ steps.meta.outputs.version }}"
docker image inspect "${{ env.SLUG_DOCKERHUB }}:${{ steps.meta.outputs.version }}"
-
name: Lowercase GHCR repository name # required because docker doesn't support uppercase chars: https://github.com/docker/build-push-action/issues/37
run: |
echo "SLUG_GHCR_LC=${SLUG_GHCR,,}" >>${GITHUB_ENV}
-
name: Inspect Image published to GHCR
run: |
docker pull "ghcr.io/${{ env.SLUG_GHCR_LC }}:${{ steps.meta.outputs.version }}"
docker image inspect "ghcr.io/${{ env.SLUG_GHCR_LC }}:${{ steps.meta.outputs.version }}"