forked from hyperledger-labs/fabric-builder-k8s
-
Notifications
You must be signed in to change notification settings - Fork 0
93 lines (84 loc) · 3.09 KB
/
docker-build.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
name: Docker CI
on:
workflow_call:
inputs:
image-name:
description: 'A Docker image name passed from the caller workflow.'
required: true
type: string
path:
description: 'A path containing a Dockerfile passed from the caller workflow.'
required: true
type: string
chaincode-label:
description: 'An optional chaincode label passed from the caller workflow. If present, will prepare a chaincode package.'
required: false
type: string
permissions:
contents: read
packages: write
id-token: write
jobs:
build:
runs-on: ubuntu-latest
outputs:
image_digest: ${{ steps.push.outputs.digest }}
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- name: Docker meta
id: meta
uses: docker/metadata-action@369eb591f429131d6889c46b94e711f089e6ca96 # v5
with:
images: |
${{ inputs.image-name }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha,format=long
- name: Set up QEMU
uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@c47758b77c9736f4b2ef4073d4d51994fabfe349 # v3
- name: Login to GitHub Container Registry
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
id: push
uses: docker/build-push-action@48aba3b46d1b1fec4febb7c5d0c644b249a11355 # v6
with:
context: .
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
package:
if: inputs.chaincode-label != '' && needs.build.outputs.image_digest != ''
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- name: Create package
uses: hyperledgendary/package-k8s-chaincode-action@ba10aea43e3d4f7991116527faf96e3c2b07abc7
with:
chaincode-label: ${{ inputs.chaincode-label }}
chaincode-image: ${{ inputs.image-name }}
chaincode-digest: ${{ needs.build.outputs.image_digest }}
- name: Rename package
if: startsWith(github.ref, 'refs/tags/v')
run: mv ${CHAINCODE_LABEL}.tgz ${CHAINCODE_LABEL}-${CHAINCODE_VERSION}.tgz
env:
CHAINCODE_LABEL: ${{ inputs.chaincode-label }}
CHAINCODE_VERSION: ${{ github.ref_name }}
- name: Upload package
run: gh release upload $GITHUB_REF_NAME ${CHAINCODE_LABEL}-${CHAINCODE_VERSION}.tgz
if: startsWith(github.ref, 'refs/tags/v')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CHAINCODE_LABEL: ${{ inputs.chaincode-label }}
CHAINCODE_VERSION: ${{ github.ref_name }}