From 392b65883bbc6873c248ef931bb835293c2b8dc5 Mon Sep 17 00:00:00 2001 From: Robert Sturla Date: Mon, 19 Dec 2022 18:07:12 +0000 Subject: [PATCH 1/6] Create .gitignore file --- .gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..485dee6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea From 05b1d981d2ca762deb9ef3bf91224f26ac4b3211 Mon Sep 17 00:00:00 2001 From: Robert Sturla Date: Mon, 19 Dec 2022 18:08:40 +0000 Subject: [PATCH 2/6] Reconfigure Containerfile to accept FEDORA_MAJOR_VERSION as ARG input --- Containerfile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Containerfile b/Containerfile index 3c6c05f..36a7559 100644 --- a/Containerfile +++ b/Containerfile @@ -1,4 +1,6 @@ -FROM ghcr.io/cgwalters/fedora-silverblue:37 +ARG FEDORA_MAJOR_VERSION=37 + +FROM ghcr.io/cgwalters/fedora-silverblue:${FEDORA_MAJOR_VERSION} # See https://pagure.io/releng/issue/11047 for final location COPY etc /etc @@ -11,4 +13,4 @@ RUN rpm-ostree override remove firefox firefox-langpacks && \ systemctl enable rpm-ostreed-automatic.timer && \ systemctl enable flatpak-automatic.timer && \ rpm-ostree cleanup -m && \ - ostree container commit \ No newline at end of file + ostree container commit From c560bfa7144541866916673f62f94c95ed0a5102 Mon Sep 17 00:00:00 2001 From: Robert Sturla Date: Mon, 19 Dec 2022 18:10:26 +0000 Subject: [PATCH 3/6] Generate all tags in separate bash step and allow multiple major versions to be built in parallel --- .github/workflows/build.yml | 42 ++++++++++++++++++++++++++++++------- 1 file changed, 35 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bbc1dc3..801642f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -7,10 +7,7 @@ on: - cron: '20 20 * * *' # 8:20pm everyday env: IMAGE_NAME: base - IMAGE_TAGS: 37 latest ${{ github.sha }} IMAGE_REGISTRY: ghcr.io/${{ github.repository_owner }} - REGISTRY_USER: ${{ github.actor }} - REGISTRY_PASSWORD: ${{ github.token }} jobs: push-ghcr: @@ -18,12 +15,35 @@ jobs: runs-on: ubuntu-22.04 strategy: fail-fast: false + matrix: + major_version: [37] + include: + - major_version: 37 + is_latest: true + is_stable: true steps: - # Checkout push-to-registry action github repository + # Checkout push-to-registry action GitHub repository - name: Checkout Push to Registry action uses: actions/checkout@v2 + - name: set env run: echo "DATE=$(date +'%Y%m%d')" >> $GITHUB_ENV + + - name: Generate tags + id: generate-tags + shell: bash + run: | + echo "date=$(date +%Y%m%d)" >> $GITHUB_OUTPUT + echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT + echo "release=${{ matrix.fedora_major_version }}" >> $GITHUB_OUTPUT + alias_tags=() + if [[ "${{ matrix.is_latest }}" == "true" ]]; then + alias_tags+=("latest") + fi + if [[ "${{ matrix.is_stable }}" == "true" ]]; then + alias_tags+=("stable") + fi + echo "alias_tags=${alias_tags[*]}" >> $GITHUB_OUTPUT # Build image using Buildah action - name: Build Image @@ -33,10 +53,16 @@ jobs: containerfiles: | ./Containerfile image: ${{ env.IMAGE_NAME }} - tags: ${{ env.IMAGE_TAGS }} ${{ env.DATE }} + tags: | + ${{ steps.generate-tags.outputs.alias_tags }} + ${{ steps.generate-tags.outputs.release }} + ${{ steps.generate-tags.outputs.date }} + ${{ steps.generate-tags.outputs.sha_short }} + build-args: | + FEDORA_MAJOR_VERSION=${{ matrix.major_version }} oci: true - # Workaround bug where capital letters in your GitHub user name make it impossible to push to GHCR. + # Workaround bug where capital letters in your GitHub username make it impossible to push to GHCR. # https://github.com/macbre/push-to-ghcr/issues/12 - name: Lowercase Registry id: registry_case @@ -48,6 +74,9 @@ jobs: - name: Push To GHCR uses: redhat-actions/push-to-registry@v2 id: push + env: + REGISTRY_USER: ${{ github.actor }} + REGISTRY_PASSWORD: ${{ github.token }} with: image: ${{ steps.build_image.outputs.image }} tags: ${{ steps.build_image.outputs.tags }} @@ -60,4 +89,3 @@ jobs: - name: Echo outputs run: | echo "${{ toJSON(steps.push.outputs) }}" - From 5761fe0db85897654decd6d18a44e5a03f393080 Mon Sep 17 00:00:00 2001 From: Robert Sturla Date: Mon, 19 Dec 2022 18:14:12 +0000 Subject: [PATCH 4/6] Remove redundant shell step to generate date --- .github/workflows/build.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 801642f..224f190 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -26,9 +26,6 @@ jobs: - name: Checkout Push to Registry action uses: actions/checkout@v2 - - name: set env - run: echo "DATE=$(date +'%Y%m%d')" >> $GITHUB_ENV - - name: Generate tags id: generate-tags shell: bash From 0c869e83808e1333110712829e94f2f312a77076 Mon Sep 17 00:00:00 2001 From: Robert Sturla Date: Mon, 19 Dec 2022 18:29:45 +0000 Subject: [PATCH 5/6] Remove empty continuation line --- Containerfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Containerfile b/Containerfile index d5ad2c5..4f02b57 100644 --- a/Containerfile +++ b/Containerfile @@ -12,5 +12,4 @@ RUN rpm-ostree override remove firefox firefox-langpacks && \ sed -i 's/#AutomaticUpdatePolicy.*/AutomaticUpdatePolicy=stage/' /etc/rpm-ostreed.conf && \ systemctl enable rpm-ostreed-automatic.timer && \ systemctl enable flatpak-automatic.timer && \ - ostree container commit From 153686a13b949ac6d2bce3f60008e5ea51caffe3 Mon Sep 17 00:00:00 2001 From: Robert Sturla Date: Mon, 19 Dec 2022 18:37:18 +0000 Subject: [PATCH 6/6] major_version doesn't need to be ran in bash as the value remains unchanged --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 49154e2..5b01ae2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -35,7 +35,7 @@ jobs: run: | echo "date=$(date +%Y%m%d)" >> $GITHUB_OUTPUT echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT - echo "release=${{ matrix.fedora_major_version }}" >> $GITHUB_OUTPUT + alias_tags=() if [[ "${{ matrix.is_latest }}" == "true" ]]; then alias_tags+=("latest") @@ -55,9 +55,9 @@ jobs: image: ${{ env.IMAGE_NAME }} tags: | ${{ steps.generate-tags.outputs.alias_tags }} - ${{ steps.generate-tags.outputs.release }} ${{ steps.generate-tags.outputs.date }} ${{ steps.generate-tags.outputs.sha_short }} + ${{ matrix.major_version }} build-args: | FEDORA_MAJOR_VERSION=${{ matrix.major_version }} oci: true