-
Notifications
You must be signed in to change notification settings - Fork 0
84 lines (71 loc) · 2.43 KB
/
build-push-docker-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
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
name: build-push-docker-image
on:
workflow_call:
inputs:
component_name:
required: true
type: string
tag:
required: true
type: string
jobs:
build-push-docker-image:
permissions:
packages: write
runs-on: ubuntu-latest
timeout-minutes: 30
env:
TAG: ${{ inputs.tag }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set repository name
id: repo-name
run: echo "REPO_NAME=$(basename $GITHUB_REPOSITORY)" >> $GITHUB_ENV
- name: Set the component name
id: component-name
run: echo "COMPONENT_NAME=$(basename ${{ inputs.component_name }})" >> $GITHUB_ENV
- name: Get the latest release
id: release
uses: robinraju/[email protected]
with:
fileName: "*.tar.bz2"
tag: "${{ inputs.tag }}"
- name: Get commit details for the tag from the latest release
id: commit_details
run: |
echo "sha=$(git rev-list -n 1 ${{ steps.release.outputs.tag_name }})" >> $GITHUB_OUTPUT
echo "commit_time=$(git show -s --format=%ci ${{ steps.release.outputs.tag_name }})" >> $GITHUB_OUTPUT
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set docker labels and tags
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/openconext/${{ env.REPO_NAME}}/${{ env.COMPONENT_NAME }}
tags: |
type=ref,event=tag
type=semver,pattern={{version}}
type=sha
type=raw,value=prod
- name: Build and push the Production image
uses: docker/build-push-action@v6
with:
context: .
file: docker/Dockerfile.prod
platforms: linux/amd64,linux/arm64
push: true
build-args: |
APP_VERSION=${{ steps.release.outputs.tag_name }}
GIT_SHA=${{ steps.commit_details.outputs.sha }}
GIT_COMMIT_TIME=${{ steps.commit_details.outputs.commit_time }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}