Skip to content

Commit

Permalink
Add GitHub Action files to build and publish
Browse files Browse the repository at this point in the history
  • Loading branch information
aguslr committed Sep 25, 2023
1 parent 7a9647c commit 0ca2286
Show file tree
Hide file tree
Showing 2 changed files with 354 additions and 0 deletions.
177 changes: 177 additions & 0 deletions .github/workflows/build-fusion.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
name: Build RPMFusion image

on:
schedule:
- cron: '50 20 * * *' # 8:50pm everyday
pull_request:
branches:
- main
paths-ignore:
- 'README*'
- '*.md'
- '*.png'
- '*.txt'
push:
branches:
- main
paths-ignore:
- 'README*'
- '*.md'
- '*.png'
- '*.txt'
workflow_dispatch:

env:
IMAGE_NAME: ${{ github.event.repository.name }}
REGISTRY_URL: ghcr.io
REGISTRY_USERNAME: ${{ github.repository_owner }}
REGISTRY_PASSWORD: ${{ secrets.GITHUB_TOKEN }}

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
id-token: write
strategy:
fail-fast: false
matrix:
major_version: [37, 38]
include:
- major_version: 37
is_latest: false
is_stable: false
- major_version: 38
is_latest: true
is_stable: true

steps:

- name: Checkout repository
uses: actions/checkout@v3

- name: Log into registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY_URL }}
username: ${{ env.REGISTRY_USERNAME }}
password: ${{ env.REGISTRY_PASSWORD }}

- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v4
with:
images: |
${{ env.REGISTRY_URL }}/${{ env.REGISTRY_USERNAME }}/${{ env.IMAGE_NAME }}
flavor: |
latest=false
tags: |
type=semver,pattern={{version}}
type=sha,prefix=sha256-
- name: Extract Docker PR tag
if: github.event_name == 'pull_request'
id: meta_pr
uses: docker/metadata-action@v4
with:
images: |
${{ env.REGISTRY_URL }}/${{ env.REGISTRY_USERNAME }}/${{ env.IMAGE_NAME }}
flavor: |
latest=false
tags: |
type=ref,suffix=-${{ matrix.major_version }}-fusion,event=pr
- name: Extract Docker date tag
if: github.event_name == 'schedule'
id: meta_date
uses: docker/metadata-action@v4
with:
images: |
${{ env.REGISTRY_URL }}/${{ env.REGISTRY_USERNAME }}/${{ env.IMAGE_NAME }}
flavor: |
latest=false
tags: |
type=schedule,prefix=${{ matrix.major_version }}-,suffix=-fusion,pattern={{date 'YYYYMMDD'}}
- name: Extract Docker major version tag
if: |
github.event_name != 'pull_request' && matrix.major_version != ''
id: meta_version
uses: docker/metadata-action@v4
with:
images: |
${{ env.REGISTRY_URL }}/${{ env.REGISTRY_USERNAME }}/${{ env.IMAGE_NAME }}
flavor: |
latest=false
tags: |
type=raw,value=${{ matrix.major_version }}-fusion
- name: Extract Docker stable tag
if: |
github.event_name != 'pull_request' && matrix.is_stable == true
id: meta_stable
uses: docker/metadata-action@v4
with:
images: |
${{ env.REGISTRY_URL }}/${{ env.REGISTRY_USERNAME }}/${{ env.IMAGE_NAME }}
flavor: |
latest=false
tags: |
type=schedule,pattern={{date 'YYYYMMDD'}},suffix=-fusion
type=raw,value=stable-fusion
- name: Extract Docker latest tag
if: |
github.event_name != 'pull_request' && matrix.is_latest == true
id: meta_latest
uses: docker/metadata-action@v4
with:
images: |
${{ env.REGISTRY_URL }}/${{ env.REGISTRY_USERNAME }}/${{ env.IMAGE_NAME }}
flavor: |
latest=false
tags: |
type=raw,value=latest-fusion
- name: Build Image
id: build_image
uses: redhat-actions/buildah-build@v2
with:
containerfiles: |
./Containerfile
tags: |
${{ steps.meta.outputs.tags }}
${{ steps.meta_pr.outputs.tags }}
${{ steps.meta_date.outputs.tags }}
${{ steps.meta_version.outputs.tags }}
${{ steps.meta_stable.outputs.tags }}
${{ steps.meta_latest.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
FEDORA_BASE=fusion
FEDORA_MAJOR_VERSION=${{ matrix.major_version }}
oci: false

- name: Push to container registries
uses: redhat-actions/push-to-registry@v2
id: push
with:
tags: ${{ steps.build_image.outputs.tags }}
extra-args: |
--disable-content-trust
- name: Install Cosign
uses: sigstore/[email protected]

- name: Sign container image
run: |
cosign sign -y --key env://COSIGN_PRIVATE_KEY ${{ env.REGISTRY_URL }}/${{ env.REGISTRY_USERNAME }}/${{ env.IMAGE_NAME }}@${TAGS}
env:
TAGS: ${{ steps.push.outputs.digest }}
COSIGN_PRIVATE_KEY: ${{ secrets.COSIGN_KEY }}
COSIGN_EXPERIMENTAL: false

- name: Echo outputs
run: |
echo "${{ toJSON(steps.push.outputs) }}"
177 changes: 177 additions & 0 deletions .github/workflows/build-vanilla.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
name: Build Vanilla image

on:
schedule:
- cron: '50 20 * * *' # 8:50pm everyday
pull_request:
branches:
- main
paths-ignore:
- 'README*'
- '*.md'
- '*.png'
- '*.txt'
push:
branches:
- main
paths-ignore:
- 'README*'
- '*.md'
- '*.png'
- '*.txt'
workflow_dispatch:

env:
IMAGE_NAME: ${{ github.event.repository.name }}
REGISTRY_URL: ghcr.io
REGISTRY_USERNAME: ${{ github.repository_owner }}
REGISTRY_PASSWORD: ${{ secrets.GITHUB_TOKEN }}

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
id-token: write
strategy:
fail-fast: false
matrix:
major_version: [37, 38]
include:
- major_version: 37
is_latest: false
is_stable: false
- major_version: 38
is_latest: true
is_stable: true

steps:

- name: Checkout repository
uses: actions/checkout@v3

- name: Log into registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY_URL }}
username: ${{ env.REGISTRY_USERNAME }}
password: ${{ env.REGISTRY_PASSWORD }}

- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v4
with:
images: |
${{ env.REGISTRY_URL }}/${{ env.REGISTRY_USERNAME }}/${{ env.IMAGE_NAME }}
flavor: |
latest=false
tags: |
type=semver,pattern={{version}}
type=sha,prefix=sha256-
- name: Extract Docker PR tag
if: github.event_name == 'pull_request'
id: meta_pr
uses: docker/metadata-action@v4
with:
images: |
${{ env.REGISTRY_URL }}/${{ env.REGISTRY_USERNAME }}/${{ env.IMAGE_NAME }}
flavor: |
latest=false
tags: |
type=ref,suffix=-${{ matrix.major_version }},event=pr
- name: Extract Docker date tag
if: github.event_name == 'schedule'
id: meta_date
uses: docker/metadata-action@v4
with:
images: |
${{ env.REGISTRY_URL }}/${{ env.REGISTRY_USERNAME }}/${{ env.IMAGE_NAME }}
flavor: |
latest=false
tags: |
type=schedule,prefix=${{ matrix.major_version }}-,pattern={{date 'YYYYMMDD'}}
- name: Extract Docker major version tag
if: |
github.event_name != 'pull_request' && matrix.major_version != ''
id: meta_version
uses: docker/metadata-action@v4
with:
images: |
${{ env.REGISTRY_URL }}/${{ env.REGISTRY_USERNAME }}/${{ env.IMAGE_NAME }}
flavor: |
latest=false
tags: |
type=raw,value=${{ matrix.major_version }}
- name: Extract Docker stable tag
if: |
github.event_name != 'pull_request' && matrix.is_stable == true
id: meta_stable
uses: docker/metadata-action@v4
with:
images: |
${{ env.REGISTRY_URL }}/${{ env.REGISTRY_USERNAME }}/${{ env.IMAGE_NAME }}
flavor: |
latest=false
tags: |
type=schedule,pattern={{date 'YYYYMMDD'}}
type=raw,value=stable
- name: Extract Docker latest tag
if: |
github.event_name != 'pull_request' && matrix.is_latest == true
id: meta_latest
uses: docker/metadata-action@v4
with:
images: |
${{ env.REGISTRY_URL }}/${{ env.REGISTRY_USERNAME }}/${{ env.IMAGE_NAME }}
flavor: |
latest=false
tags: |
type=raw,value=latest
- name: Build Image
id: build_image
uses: redhat-actions/buildah-build@v2
with:
containerfiles: |
./Containerfile
tags: |
${{ steps.meta.outputs.tags }}
${{ steps.meta_pr.outputs.tags }}
${{ steps.meta_date.outputs.tags }}
${{ steps.meta_version.outputs.tags }}
${{ steps.meta_stable.outputs.tags }}
${{ steps.meta_latest.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
FEDORA_BASE=vanilla
FEDORA_MAJOR_VERSION=${{ matrix.major_version }}
oci: false

- name: Push to container registries
uses: redhat-actions/push-to-registry@v2
id: push
with:
tags: ${{ steps.build_image.outputs.tags }}
extra-args: |
--disable-content-trust
- name: Install Cosign
uses: sigstore/[email protected]

- name: Sign container image
run: |
cosign sign -y --key env://COSIGN_PRIVATE_KEY ${{ env.REGISTRY_URL }}/${{ env.REGISTRY_USERNAME }}/${{ env.IMAGE_NAME }}@${TAGS}
env:
TAGS: ${{ steps.push.outputs.digest }}
COSIGN_PRIVATE_KEY: ${{ secrets.COSIGN_KEY }}
COSIGN_EXPERIMENTAL: false

- name: Echo outputs
run: |
echo "${{ toJSON(steps.push.outputs) }}"

0 comments on commit 0ca2286

Please sign in to comment.