Skip to content

Commit f6984a3

Browse files
committed
Move all config to a common action
1 parent 6772859 commit f6984a3

File tree

4 files changed

+86
-64
lines changed

4 files changed

+86
-64
lines changed

.github/actions/config/action.yml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
---
2+
name: Set Environment Variables
3+
4+
inputs:
5+
VARIANT:
6+
description: "The desktop variant to build. Use 'ALL' to build all variants."
7+
required: false
8+
9+
outputs:
10+
LATEST_TAG:
11+
description: "The latest tag based on the event type"
12+
value: ${{ steps.set.outputs.LATEST_TAG }}
13+
REGISTRY:
14+
description: "The container registry to use"
15+
value: ${{ steps.set.outputs.REGISTRY }}
16+
REGISTRY_USER:
17+
description: "The user for the container registry"
18+
value: ${{ steps.set.outputs.REGISTRY_USER }}
19+
PLATFORMS:
20+
description: "The platforms to build for"
21+
value: ${{ steps.set.outputs.PLATFORMS }}
22+
IMAGE_PATH:
23+
description: "The path to the image in the registry"
24+
value: ${{ steps.set.outputs.IMAGE_PATH }}
25+
IMAGE_NAME:
26+
description: "The name of the image"
27+
value: ${{ steps.set.outputs.IMAGE_NAME }}
28+
IMAGE_REF:
29+
description: "The full reference to the image in the registry"
30+
value: ${{ steps.set.outputs.IMAGE_REF }}
31+
VARIANTS:
32+
description: "The desktop variants to build"
33+
value: ${{ steps.set.outputs.VARIANTS }}
34+
MATRIX:
35+
description: "The matrix of variants to build"
36+
value: ${{ steps.set.outputs.MATRIX }}
37+
IS_SIGNED:
38+
description: "Whether the image is signed"
39+
value: ${{ steps.set.outputs.IS_SIGNED }}
40+
41+
runs:
42+
using: "composite"
43+
steps:
44+
- name: Set environment variables
45+
id: set
46+
shell: bash
47+
run: |
48+
# Pick a latest tag based on the event type
49+
if [[ "${{ github.ref }}" != "refs/heads/${{ github.event.repository.default_branch }}" ]]; then
50+
echo "LATEST_TAG=${{ github.ref_name }}" >> $GITHUB_OUTPUT
51+
else
52+
echo "LATEST_TAG=latest" >> $GITHUB_OUTPUT
53+
fi
54+
55+
REGISTRY=ghcr.io
56+
REGISTRY_USER=${{ github.actor }}
57+
IMAGE_PATH=${{ github.repository_owner }}
58+
IMAGE_NAME=${{ github.event.repository.name }}
59+
PLATFORMS="amd64"
60+
61+
echo "REGISTRY=${REGISTRY}" >> $GITHUB_OUTPUT
62+
echo "REGISTRY_USER=${REGISTRY_USER}" >> $GITHUB_OUTPUT
63+
echo "IMAGE_PATH=${IMAGE_PATH}" >> $GITHUB_OUTPUT
64+
echo "IMAGE_NAME=${IMAGE_NAME}" >> $GITHUB_OUTPUT
65+
echo "IMAGE_REF=${REGISTRY}/${IMAGE_PATH}/${IMAGE_NAME}" >> $GITHUB_OUTPUT
66+
echo "PLATFORMS=${PLATFORMS}" >> $GITHUB_OUTPUT
67+
68+
# This is a workaround so that the expansion of secrets.SIGNING_SECRET doesn't break the if statement
69+
SECRET=$(cat <<EOF
70+
${{ secrets.SIGNING_SECRET }}
71+
EOF
72+
)
73+
if [ -z "${SECRET}" ]; then
74+
echo "IS_SIGNED=false" >> $GITHUB_OUTPUT
75+
else
76+
echo "IS_SIGNED=true" >> $GITHUB_OUTPUT
77+
fi

.github/workflows/build-iso.yml

Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -22,39 +22,12 @@ jobs:
2222
IMAGE_REF: ${{ steps.set.outputs.IMAGE_REF }}
2323
IS_SIGNED: ${{ steps.set.outputs.IS_SIGNED }}
2424
steps:
25+
- name: Checkout github actions
26+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
27+
2528
- name: Set environment variables
29+
uses: ./.github/actions/config
2630
id: set
27-
run: |
28-
# Pick a latest tag based on the event type
29-
if [[ "${{ github.ref }}" != "refs/heads/${{ github.event.repository.default_branch }}" ]]; then
30-
echo "LATEST_TAG=${{ github.ref_name }}" >> $GITHUB_OUTPUT
31-
else
32-
echo "LATEST_TAG=latest" >> $GITHUB_OUTPUT
33-
fi
34-
35-
REGISTRY=ghcr.io
36-
REGISTRY_USER=${{ github.actor }}
37-
IMAGE_PATH=${{ github.repository_owner }}
38-
IMAGE_NAME=${{ github.event.repository.name }}
39-
PLATFORMS="amd64"
40-
41-
echo "REGISTRY=${REGISTRY}" >> $GITHUB_OUTPUT
42-
echo "REGISTRY_USER=${REGISTRY_USER}" >> $GITHUB_OUTPUT
43-
echo "IMAGE_PATH=${IMAGE_PATH}" >> $GITHUB_OUTPUT
44-
echo "IMAGE_NAME=${IMAGE_NAME}" >> $GITHUB_OUTPUT
45-
echo "IMAGE_REF=${REGISTRY}/${IMAGE_PATH}/${IMAGE_NAME}" >> $GITHUB_OUTPUT
46-
echo "PLATFORMS=${PLATFORMS}" >> $GITHUB_OUTPUT
47-
48-
# This is a workaround so that the expansion of secrets.SIGNING_SECRET doesn't break the if statement
49-
SECRET=$(cat <<EOF
50-
${{ secrets.SIGNING_SECRET }}
51-
EOF
52-
)
53-
if [ -z "${SECRET}" ]; then
54-
echo "IS_SIGNED=false" >> $GITHUB_OUTPUT
55-
else
56-
echo "IS_SIGNED=true" >> $GITHUB_OUTPUT
57-
fi
5831

5932
build-iso:
6033
name: Build ISO

.github/workflows/build.yml

Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -28,39 +28,12 @@ jobs:
2828
IMAGE_REF: ${{ steps.set.outputs.IMAGE_REF }}
2929
IS_SIGNED: ${{ steps.set.outputs.IS_SIGNED }}
3030
steps:
31+
- name: Checkout github actions
32+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
33+
3134
- name: Set environment variables
35+
uses: ./.github/actions/config
3236
id: set
33-
run: |
34-
# Pick a latest tag based on the event type
35-
if [[ "${{ github.ref }}" != "refs/heads/${{ github.event.repository.default_branch }}" ]]; then
36-
echo "LATEST_TAG=${{ github.ref_name }}" >> $GITHUB_OUTPUT
37-
else
38-
echo "LATEST_TAG=latest" >> $GITHUB_OUTPUT
39-
fi
40-
41-
REGISTRY=ghcr.io
42-
REGISTRY_USER=${{ github.actor }}
43-
IMAGE_PATH=${{ github.repository_owner }}
44-
IMAGE_NAME=${{ github.event.repository.name }}
45-
PLATFORMS="amd64"
46-
47-
echo "REGISTRY=${REGISTRY}" >> $GITHUB_OUTPUT
48-
echo "REGISTRY_USER=${REGISTRY_USER}" >> $GITHUB_OUTPUT
49-
echo "IMAGE_PATH=${IMAGE_PATH}" >> $GITHUB_OUTPUT
50-
echo "IMAGE_NAME=${IMAGE_NAME}" >> $GITHUB_OUTPUT
51-
echo "IMAGE_REF=${REGISTRY}/${IMAGE_PATH}/${IMAGE_NAME}" >> $GITHUB_OUTPUT
52-
echo "PLATFORMS=${PLATFORMS}" >> $GITHUB_OUTPUT
53-
54-
# This is a workaround so that the expansion of secrets.SIGNING_SECRET doesn't break the if statement
55-
SECRET=$(cat <<EOF
56-
${{ secrets.SIGNING_SECRET }}
57-
EOF
58-
)
59-
if [ -z "${SECRET}" ]; then
60-
echo "IS_SIGNED=false" >> $GITHUB_OUTPUT
61-
else
62-
echo "IS_SIGNED=true" >> $GITHUB_OUTPUT
63-
fi
6437

6538
build-image:
6639
name: Build image

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ Welcome to your brand-new Atomic AlmaLinux Respin!
66

77
### Set basic configuration
88

9-
In the ["Build image"](.github/workflows/build.yml) and ["Build ISOs"](.github/workflows/build-iso.yml)
10-
workflows, you'll find a `set-env` job where you can configure several key variables:
9+
In the ["config"](.github/actions/config/action.yml) action, you'll find a job where you can configure several key variables:
1110

1211
- `REGISTRY`: The container registry to push your image to (default: GitHub Container Registry `ghcr.io`).
1312
- `REGISTRY_USER`: Your username for the registry.

0 commit comments

Comments
 (0)