Skip to content
46 linesCodeBlameRaw
1name: Docker
2on:
3 schedule:
4 - cron: '27 4 * * *'
5 push:
6 branches: [ "main" ]
7 tags: [ 'v*.*.*' ]
8 pull_request:
9 branches: [ "main" ]
10env:
11 REGISTRY: ghcr.io
12 IMAGE_NAME: ${{ github.repository }}
13jobs:
14 build:
15 runs-on: ubuntu-latest
16 permissions:
17 contents: read
18 packages: write
19 id-token: write
20 steps:
21 - name: Checkout repository
22 uses: actions/checkout@v4
23 - name: Set up Docker Buildx
24 uses: docker/setup-buildx-action@v3
25 - name: Log into registry ${{ env.REGISTRY }}
26 if: github.event_name != 'pull_request'
27 uses: docker/login-action@v3
28 with:
29 registry: ${{ env.REGISTRY }}
30 username: ${{ github.actor }}
31 password: ${{ secrets.GITHUB_TOKEN }}
32 - name: Extract Docker metadata
33 id: meta
34 uses: docker/metadata-action@v5
35 with:
36 images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
37 - name: Build and push Docker image
38 id: build-and-push
39 uses: docker/build-push-action@v6
40 with:
41 context: .
42 push: ${{ github.event_name != 'pull_request' }}
43 tags: ${{ steps.meta.outputs.tags }}
44 labels: ${{ steps.meta.outputs.labels }}
45 cache-from: type=gha
46 cache-to: type=gha,mode=max