-
Notifications
You must be signed in to change notification settings - Fork 560
66 lines (60 loc) · 2.18 KB
/
_buildx.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
57
58
59
60
61
62
63
64
65
66
name: "Build Docker"
on:
workflow_call:
inputs:
tag_prefix:
description: 'The tag prefix to use'
required: false
type: string
default: ''
dockerfile:
description: 'The Dockerfile to use'
required: false
type: string
default: 'Dockerfile'
jobs:
buildx:
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
name: Build Docker
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # 4.1.8
with:
name: dist
path: ./dist
# Every pull request that goes into master
- name: Prepare master push tags
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
run: |
REPO=ghcr.io/${{ github.repository }}
TAG=$(git describe --tags)
echo "tag_flags=--tag $REPO:${{ inputs.tag_prefix }}$TAG" >> $GITHUB_ENV
# New tagged version
- name: Prepare version push tags
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
run: |
REPO=ghcr.io/${{ github.repository }}
TAG=$(git describe --tags)
if [[ "$TAG" == *"rc"* ]]
then
TAG2="dev"
else
TAG2="latest"
fi
echo "tag_flags=--tag $REPO:${{ inputs.tag_prefix }}$TAG --tag $REPO:${{ inputs.tag_prefix }}$TAG2" >> $GITHUB_ENV
# Every pull request
- name: Prepare pull request tags
if: github.event_name == 'pull_request'
run: |
echo "tag_flags=--tag ${{ github.ref }}" >> $GITHUB_ENV
REPO=ghcr.io/${{ github.repository }}
echo "tag_flags=--tag $REPO:${{ inputs.tag_prefix }}pr-${{ github.event.pull_request.number }}" >> $GITHUB_ENV
- name: Buildx
run: |
set -x
echo "${{ secrets.GITHUB_TOKEN }}" | docker login -u "${{ github.repository_owner }}" --password-stdin ghcr.io
make buildx CONTAINERFILE_NAME=${{ inputs.dockerfile }} CONTAINER_BUILDX_OPTIONS="--push ${{ env.tag_flags }}"