-
Notifications
You must be signed in to change notification settings - Fork 10
56 lines (54 loc) · 2.32 KB
/
Copy pathdocker.yml
File metadata and controls
56 lines (54 loc) · 2.32 KB
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
name: Build and Push Docker Image to GHCR
on:
push:
branches:
- 'master'
pull_request:
jobs:
compat-kit:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write # Required to push packages to GHCR
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
persist-credentials: false
- uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1
with:
driver: docker-container
- uses: docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1 # v3.5.0
with:
registry: ghcr.io
username: ${{ github.actor }} # Uses the GitHub user/org name that triggered the workflow
password: ${{ secrets.GITHUB_TOKEN }} # Automatically provided by GitHub
- name: Generate image tags
id: meta
env:
REF: ${{ github.ref }}
EVENT_NAME: ${{ github.event_name }}
REPOSITORY: ${{ github.repository }}
EVENT_NUMBER: ${{ github.event.number }}
run: |
if [[ "$REF" == "refs/heads/master" ]]; then
echo "tags=ghcr.io/$REPOSITORY/compat-kit:latest" >> $GITHUB_OUTPUT
echo "push=true" >> $GITHUB_OUTPUT
elif [[ "$EVENT_NAME" == "pull_request" ]]; then
echo "tags=ghcr.io/$REPOSITORY/compat-kit:pr-$EVENT_NUMBER" >> $GITHUB_OUTPUT
echo "push=true" >> $GITHUB_OUTPUT
else
echo "push=false" >> $GITHUB_OUTPUT
fi
echo "created=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT
- uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
with:
context: ./
file: ./compat_kit/Dockerfile
push: ${{ steps.meta.outputs.push }}
tags: ${{ steps.meta.outputs.tags }}
labels: |
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
org.opencontainers.image.created=${{ steps.meta.outputs.created }}
cache-from: type=gha,scope=${{ github.ref_name }}-compat-kit # Cache layers to speed up builds
cache-to: type=gha,mode=max,scope=${{ github.ref_name }}-compat-kit # Store layers in cache for future builds