Skip to content

Commit 1d728bf

Browse files
authored
Update docker-publish.yml
1 parent bdf4b0f commit 1d728bf

1 file changed

Lines changed: 44 additions & 34 deletions

File tree

.github/workflows/docker-publish.yml

Lines changed: 44 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -7,57 +7,67 @@ name: Docker
77

88
on:
99
schedule:
10-
- cron: '32 0 * * *'
10+
- cron: "0 10 * * *"
1111
push:
12-
branches: [ main ]
13-
# Publish semver tags as releases.
14-
tags: [ 'v*.*.*' ]
12+
branches:
13+
- "**"
14+
tags:
15+
- "v*.*.*"
1516
pull_request:
16-
branches: [ main ]
17+
branches:
18+
- "main"
1719

1820
env:
1921
# Use docker.io for Docker Hub if empty
2022
REGISTRY: ghcr.io
2123
# github.repository as <account>/<repo>
2224
IMAGE_NAME: ${{ github.repository }}
2325

24-
2526
jobs:
26-
build:
27-
27+
docker:
2828
runs-on: ubuntu-latest
29-
permissions:
30-
contents: read
31-
packages: write
32-
3329
steps:
34-
- name: Checkout repository
35-
uses: actions/checkout@v2
36-
37-
# Login against a Docker registry except on PR
38-
# https://github.com/docker/login-action
39-
- name: Log into registry ${{ env.REGISTRY }}
30+
- name: Checkout
31+
uses: actions/checkout@v4
32+
- name: Docker meta
33+
id: meta
34+
uses: docker/metadata-action@v5
35+
with:
36+
# list of Docker images to use as base name for tags
37+
images: |
38+
name/app
39+
ghcr.io/username/app
40+
# generate Docker tags based on the following events/attributes
41+
tags: |
42+
type=schedule
43+
type=ref,event=branch
44+
type=ref,event=pr
45+
type=semver,pattern={{version}}
46+
type=semver,pattern={{major}}.{{minor}}
47+
type=semver,pattern={{major}}
48+
type=sha
49+
- name: Set up QEMU
50+
uses: docker/setup-qemu-action@v3
51+
- name: Set up Docker Buildx
52+
uses: docker/setup-buildx-action@v3
53+
- name: Login to Docker Hub
4054
if: github.event_name != 'pull_request'
41-
uses: docker/login-action@v2
55+
uses: docker/login-action@v3
4256
with:
43-
registry: ${{ env.REGISTRY }}
44-
username: ${{ github.actor }}
45-
password: ${{ secrets.GITHUB_TOKEN }}
46-
47-
# Extract metadata (tags, labels) for Docker
48-
# https://github.com/docker/metadata-action
49-
- name: Extract Docker metadata
50-
id: meta
51-
uses: docker/metadata-action@v2
57+
username: ${{ secrets.DOCKERHUB_USERNAME }}
58+
password: ${{ secrets.DOCKERHUB_TOKEN }}
59+
- name: Login to GHCR
60+
if: github.event_name != 'pull_request'
61+
uses: docker/login-action@v3
5262
with:
53-
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
54-
55-
# Build and push Docker image with Buildx (don't push on PR)
56-
# https://github.com/docker/build-push-action
57-
- name: Build and push Docker image
58-
uses: docker/build-push-action@v3
63+
registry: ghcr.io
64+
username: ${{ github.repository_owner }}
65+
password: ${{ secrets.GITHUB_TOKEN }}
66+
- name: Build and push
67+
uses: docker/build-push-action@v5
5968
with:
6069
context: .
6170
push: ${{ github.event_name != 'pull_request' }}
6271
tags: ${{ steps.meta.outputs.tags }}
6372
labels: ${{ steps.meta.outputs.labels }}
73+

0 commit comments

Comments
 (0)