-
Notifications
You must be signed in to change notification settings - Fork 6
115 lines (104 loc) · 3.65 KB
/
reusable_workflow.yaml
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
name: ACT Reusable Workflow to Build and Push Image
on:
workflow_call:
inputs:
image_name:
required: true
type: string
image_tag:
required: true
type: string
quay_img_exp:
required: false
type: string
quay_custom_namespace:
required: false
type: string
github_username:
required: false
type: string
github_namespace:
required: false
type: string
archetype:
required: false
type: string
multi_arch:
required: false
type: boolean
build_platforms:
required: false
type: string
default: linux/amd64, linux/arm64
secrets:
QUAY_NAMESPACE:
required: false
QUAY_USERNAME:
required: false
QUAY_PASSWORD:
required: false
env:
QUAY_TAG_ROOT: quay.io/${{ secrets.QUAY_NAMESPACE }}/${{ inputs.image_name }}
QUAY_IMG_EXP: 0
jobs:
act-build:
name: Build ${{ github.ref_name }} from ${{ github.event_name }}
runs-on: ubuntu-latest
steps:
- name: Set image tags for release
if: github.event_name == 'release'
run: |
echo "IMAGE_TAGS=${{ env.QUAY_TAG_ROOT }}:${GITHUB_REF#refs/*/} ${{ env.QUAY_TAG_ROOT }}:latest" >> $GITHUB_ENV
- name: Set image tags for main
if: github.ref == 'refs/heads/main' && github.event_name != 'release'
run: |
echo "IMAGE_TAGS=${{ env.QUAY_TAG_ROOT }}:main_latest" >> $GITHUB_ENV
- name: Set image tags and expiration for dev
if: github.ref != 'refs/heads/main' && github.event_name != 'release'
run: |
export commit_hash=${{ github.sha }}
echo "QUAY_IMG_EXP=90d" >> $GITHUB_ENV
echo "IMAGE_TAGS=${{ env.QUAY_TAG_ROOT }}:${GITHUB_REF##*/}_${commit_hash:0:7}" >> $GITHUB_ENV
- name: Checkout this project
uses: actions/checkout@v4
- name: arcaflow-container-toolkit-action
uses: arcalot/[email protected]
with:
image_name: ${{ inputs.image_name }}
image_tag: ${{ inputs.image_tag }}
github_username: ${{ inputs.github_username }}
github_password: ${{ secrets.GITHUB_TOKEN }}
github_namespace: ${{ inputs.github_namespace }}
quay_username: ${{ secrets.QUAY_USERNAME }}
quay_password: ${{ secrets.QUAY_PASSWORD }}
quay_namespace: ${{ secrets.QUAY_NAMESPACE }}
quay_custom_namespace: ${{ inputs.quay_custom_namespace }}
quay_img_exp: ${{ inputs.quay_img_exp }}
build_timeout: ${{ inputs.build_timeout }}
archetype: ${{ inputs.archetype }}
req_check_only: ${{ inputs.multi_arch }}
- name: Install qemu dependency
run: |
sudo apt-get update
sudo apt-get install -y qemu-user-static
- name: Log in to quay.io
uses: redhat-actions/podman-login@v1
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}
- name: Build multi-arch image
id: build-multi-arch
uses: redhat-actions/buildah-build@v2
with:
context: .
platforms: ${{ inputs.build_platforms }}
tags: ${{ env.IMAGE_TAGS }}
containerfiles: |
./Dockerfile
labels: quay.expires-after=${{ env.QUAY_IMG_EXP }}
- name: Push image to quay.io
uses: redhat-actions/push-to-registry@v2
with:
image: ${{ steps.build-multi-arch.outputs.image }}
tags: ${{ steps.build-multi-arch.outputs.tags }}