-
Notifications
You must be signed in to change notification settings - Fork 6
70 lines (68 loc) · 2.77 KB
/
custom-package-container.yml
File metadata and controls
70 lines (68 loc) · 2.77 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
66
67
68
69
70
# SPDX-License-Identifier: Apache-2.0
# Copyright 2022 Atlan Pte. Ltd.
name: "Custom package container"
permissions:
contents: read
packages: write
on:
workflow_call:
inputs:
package_name:
required: true
type: string
version:
required: true
type: string
branch:
required: false
type: string
default: ''
jobs:
custom-package-container:
runs-on: ubuntu-latest
name: "${{inputs.package_name}} container"
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
ref: ${{ inputs.branch != '' && inputs.branch || github.ref }}
- uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
- name: Log in to container registry
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create assembly area
run: |
mkdir -p ./containers/custom-package/assembly
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: "${{inputs.package_name}}-amd64"
path: ./containers/custom-package/amd64/assembly
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: "${{inputs.package_name}}-arm64"
path: ./containers/custom-package/arm64/assembly
- name: Determine image tags and version
id: tags
run: |
if [ -n "${{ inputs.branch }}" ]; then
# For manual runs with branch specified, use version and branch name (sanitized)
BRANCH_NAME=$(echo "${{ inputs.branch }}" | sed 's/[^a-zA-Z0-9._-]/-/g')
echo "tags=ghcr.io/atlanhq/csa-${{inputs.package_name}}:${{inputs.version}}-${BRANCH_NAME}" >> $GITHUB_OUTPUT
echo "build_version=${{inputs.version}}-${BRANCH_NAME}" >> $GITHUB_OUTPUT
else
# For main branch pushes, use version and latest
echo "tags=ghcr.io/atlanhq/csa-${{inputs.package_name}}:${{inputs.version}},ghcr.io/atlanhq/csa-${{inputs.package_name}}:latest" >> $GITHUB_OUTPUT
echo "build_version=${{inputs.version}}" >> $GITHUB_OUTPUT
fi
- name: Build and publish container image
uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7.1.0
with:
build-args: |
VERSION=${{ steps.tags.outputs.build_version }}
PKG_NAME=${{inputs.package_name}}
push: true
tags: ${{ steps.tags.outputs.tags }}
context: ./containers/custom-package
platforms: linux/amd64,linux/arm64