-
Notifications
You must be signed in to change notification settings - Fork 1
84 lines (72 loc) · 2.45 KB
/
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
name: Build and push image to GitHub Container Registry
on:
push:
paths-ignore:
- "**.md"
pull_request:
workflow_dispatch:
env:
REGISTRY: ghcr.io
IMAGE_NAME: yacoob/interactive
SHOULD_PUSH: ${{ (github.event_name == 'push' && github.ref == 'refs/heads/main') }}
jobs:
build:
name: Build and optionally push ${{ matrix.target }} image
runs-on: ubuntu-latest
strategy:
max-parallel: 1
matrix:
target: [base, devenv]
permissions:
contents: read
packages: write
attestations: write
id-token: write
steps:
- name: Set image names
run: |
echo "TARGET=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v4
- name: Log in to GitHub Container Registry
if: ${{ env.SHOULD_PUSH == 'true' }}
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Work out container tags
uses: docker/metadata-action@v5
id: docker-meta
with:
images: ${{ env.TARGET }}
tags: |
type=sha,suffix=-${{ matrix.target }}
type=raw,value=${{ matrix.target }},enable={{ is_default_branch }}
- name: Set up docker builder (buildx)
uses: docker/setup-buildx-action@v3
- name: Build and optionally push the ${{ matrix.target }} version
uses: docker/build-push-action@v6
id: build
with:
target: ${{ matrix.target }}
context: .
file: ./docker/Containerfile
push: ${{ env.SHOULD_PUSH == 'true' }}
labels: ${{ steps.docker-meta.outputs.labels }}
tags: ${{ steps.docker-meta.outputs.tags }}
cache-to: type=gha,mode=max
cache-from: type=gha
- name: Notify dependent repositories
if: ${{ env.SHOULD_PUSH == 'true' && matrix.target == 'base' }}
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ secrets.PUBLIC_REPO_TOKEN }}
repository: yacoob/docker-beets
event-type: dependency-updated
- name: Generate artifact attestation
uses: actions/attest-build-provenance@v1
with:
subject-name: ${{ env.TARGET }}
subject-digest: ${{ steps.build.outputs.digest }}
push-to-registry: ${{ env.SHOULD_PUSH == 'true' }}