-
Notifications
You must be signed in to change notification settings - Fork 3
65 lines (64 loc) · 2.5 KB
/
Copy pathjob-docker-build-push.yml
File metadata and controls
65 lines (64 loc) · 2.5 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
57
58
59
60
61
62
63
64
65
name: Docker Build and Push
on:
workflow_call:
inputs:
imageTagName:
required: true
type: string
version:
required: false
type: string
default: 'latest'
release_branch:
required: false
type: string
default: "main"
multiarch:
required: false
type: boolean
default: true
jobs:
docker:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
id-token: write
steps:
- name: Login to GitHub Container Registry
uses: docker/login-action@b45d80f862d83dbcd57f89517bcf500b2ab88fb2 # v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4
- name: Build and push
id: build
uses: docker/build-push-action@d08e5c354a6adb9ed34480a06d141179aa583294 # v7
with:
push: ${{ (github.head_ref || github.ref) == format('refs/heads/{0}',inputs.release_branch) }}
platforms: ${{ (inputs.multiarch && (github.head_ref || github.ref) == format('refs/heads/{0}',inputs.release_branch)) && 'linux/amd64,linux/arm64' || 'linux/amd64' }}
tags: ${{ inputs.imageTagName }}:${{ inputs.version }}
context: .
secrets: |
github_token=${{ secrets.GITHUB_TOKEN }}
common_repository_token=${{ secrets.COMMON_REPOSITORY_TOKEN }}
- name: Install Cosign
if: ${{ (github.head_ref || github.ref) == format('refs/heads/{0}',inputs.release_branch) }}
uses: sigstore/cosign-installer@6f9f17788090df1f26f669e9d70d6ae9567deba6 # v4.1.2
- name: Sign container image
if: ${{ (github.head_ref || github.ref) == format('refs/heads/{0}',inputs.release_branch) }}
run: cosign sign --yes ${{ inputs.imageTagName }}@${{ steps.build.outputs.digest }}
- name: Create Release
if: ${{ (github.head_ref || github.ref) == format('refs/heads/{0}',inputs.release_branch) }}
uses: ncipollo/release-action@339a81892b84b4eeb0f6e744e4574d79d0d9b8dd # v1.21.0
with:
allowUpdates: true
draft: false
makeLatest: true
generateReleaseNotes: true
tag: ${{ inputs.version }}
name: ${{ inputs.version }}
token: ${{ secrets.GITHUB_TOKEN }}