forked from traefik/traefik
-
Notifications
You must be signed in to change notification settings - Fork 0
56 lines (48 loc) · 1.67 KB
/
publish-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
---
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
name: "Container: Image Build"
on:
workflow_dispatch:
inputs:
publish:
description: Publish the container to the registry
required: true
type: boolean
default: false
jobs:
publish-images:
name: Publish Image
permissions:
contents: write
packages: write
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Log into registry ghcr.io
uses: docker/login-action@v3.3.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3.2.0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3.6.1
- name: Build and publish image
env:
DOCKER_BUILDX_ARGS: "--load --cache-from type=gha --cache-to type=gha,mode=max"
run: |
make build-image-dirty
- name: Set image tag
run: |
git remote add upstream https://github.com/traefik/traefik.git
git fetch --tags upstream
echo "VERSION=$(git describe --tags --match 'v2.*' --exclude '*-' --abbrev=0)" >> $GITHUB_ENV
- name: Push image
if: ${{inputs.publish}}
run: |
docker tag traefik/traefik ghcr.io/${{ github.repository }}:${VERSION}-${GITHUB_SHA::7}
docker push ghcr.io/${{ github.repository }}:${VERSION}-${GITHUB_SHA::7}