Merge pull request #66 from lmilbaum/refactoring

Refactor GitHub Action workflows
This commit is contained in:
Liora Milbaum 2023-11-23 17:11:47 +02:00 committed by GitHub
commit 944663f3e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 51 deletions

View File

@ -1,6 +1,12 @@
name: publish-image name: Build and Push Image
on: on:
pull_request:
branches:
- main
paths-ignore:
- "docs/**"
push: push:
branches: branches:
- main - main
@ -9,16 +15,12 @@ on:
workflow_dispatch: workflow_dispatch:
env:
REGISTRY: quay.io
QUAY_ORG: centos-bootc
jobs: jobs:
build-and-push-image: build-and-push-image:
runs-on: ubuntu-latest runs-on: ubuntu-latest
container: container:
image: quay.io/centos-boot/builder:latest image: quay.io/centos-bootc/builder:latest
options: --privileged options: --privileged
strategy: strategy:
@ -34,17 +36,27 @@ jobs:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
# The --privileged bits seem to trip this up - name: Workaround git safe.directory
- name: Ensure git safe directory
run: git config --global --add safe.directory '*' run: git config --global --add safe.directory '*'
- name: Set SOURCE_DATE_EPOCH - name: Set SOURCE_DATE_EPOCH
run: echo SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct) >> $GITHUB_ENV run: echo SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct) >> $GITHUB_ENV
- name: Build and Push - name: Login to quay.io
run: | run: |
echo "${{ secrets.QUAY_PASSWORD }}" | skopeo login -u "${{ secrets.QUAY_USER }}" \ echo "${{ secrets.QUAY_PASSWORD }}" | skopeo login -u "${{ secrets.QUAY_USER }}" \
--password-stdin ${{ env.REGISTRY }} --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 \ rpm-ostree compose image --initialize-mode if-not-exists \
--format=registry ${{ matrix.os }}-bootc.yaml \ --format=registry ${{ matrix.os }}-bootc.yaml \
${{ env.REGISTRY }}/${{ env.QUAY_ORG }}/${{ matrix.os }}-bootc:${{ matrix.version }} ${{ env.REGISTRY }}/${{ env.QUAY_ORG }}/${{ matrix.os }}-bootc:${{ matrix.version }}
if: ${{ github.event_name == 'push' }}

View File

@ -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