From f5f05dd22f0be4aff5ed0307c66db090cadfdd4a Mon Sep 17 00:00:00 2001 From: Liora Milbaum Date: Thu, 23 Nov 2023 16:55:21 +0200 Subject: [PATCH] Refactor GitHub Action workflows --- ...ish-image.yml => build-and-push-image.yml} | 30 +++++++++---- .github/workflows/ci.yml | 42 ------------------- 2 files changed, 21 insertions(+), 51 deletions(-) rename .github/workflows/{publish-image.yml => build-and-push-image.yml} (66%) delete mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/publish-image.yml b/.github/workflows/build-and-push-image.yml similarity index 66% rename from .github/workflows/publish-image.yml rename to .github/workflows/build-and-push-image.yml index 97a411f..06f18d3 100644 --- a/.github/workflows/publish-image.yml +++ b/.github/workflows/build-and-push-image.yml @@ -1,6 +1,12 @@ -name: publish-image +name: Build and Push Image on: + pull_request: + branches: + - main + paths-ignore: + - "docs/**" + push: branches: - main @@ -9,16 +15,12 @@ on: workflow_dispatch: -env: - REGISTRY: quay.io - QUAY_ORG: centos-bootc - jobs: build-and-push-image: runs-on: ubuntu-latest container: - image: quay.io/centos-boot/builder:latest + image: quay.io/centos-bootc/builder:latest options: --privileged strategy: @@ -34,17 +36,27 @@ jobs: - name: Checkout repository uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - # The --privileged bits seem to trip this up - - name: Ensure git safe directory + - name: Workaround git safe.directory run: git config --global --add safe.directory '*' - name: Set SOURCE_DATE_EPOCH run: echo SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct) >> $GITHUB_ENV - - name: Build and Push + - name: Login to quay.io run: | echo "${{ secrets.QUAY_PASSWORD }}" | skopeo login -u "${{ secrets.QUAY_USER }}" \ --password-stdin ${{ env.REGISTRY }} + if: ${{ github.event_name == 'push' }} + + - name: Build + run: | + rpm-ostree compose image --format=ociarchive \ + --initialize ${{ matrix.os }}-bootc.yaml dest.oci-archive + if: ${{ github.event_name == 'pull_request' }} + + - name: Build and Push + run: | rpm-ostree compose image --initialize-mode if-not-exists \ --format=registry ${{ matrix.os }}-bootc.yaml \ ${{ env.REGISTRY }}/${{ env.QUAY_ORG }}/${{ matrix.os }}-bootc:${{ matrix.version }} + if: ${{ github.event_name == 'push' }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index e57e6d0..0000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,42 +0,0 @@ -name: ci - -on: - pull_request: - branches: - - main - paths-ignore: - - "docs/**" - - workflow_dispatch: - -jobs: - build-image: - runs-on: ubuntu-latest - - container: - image: quay.io/centos-bootc/builder:latest - options: --privileged - - strategy: - matrix: - os: [fedora, centos] - include: - - os: fedora - version: eln - - os: centos - version: stream9 - - steps: - - name: Checkout repository - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - - - name: Workaround git safe.directory - run: git config --global --add safe.directory '*' - - - name: Set SOURCE_DATE_EPOCH - run: echo SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct) >> $GITHUB_ENV - - - name: Build - run: | - rpm-ostree compose image --format=ociarchive \ - --initialize ${{ matrix.os }}-bootc.yaml dest.oci-archive