Skip to content

Commit

Permalink
Create dedicated workflows for the lite image
Browse files Browse the repository at this point in the history
  • Loading branch information
gummigroda committed Oct 11, 2024
1 parent 0cea804 commit 0f5cec2
Show file tree
Hide file tree
Showing 4 changed files with 128 additions and 0 deletions.
65 changes: 65 additions & 0 deletions .github/workflows/shared-steps.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
on:
workflow_call:
inputs:
registry:
required: true
type: string
do_tag:
required: true
type: string # boolean exists, but that will be a string as ENV VAR. Set to YES or NOPE
secrets:
token:
required: true

jobs:
reusable:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to GitHub Container Registry
if: ${{github.event_name != 'pull_request'}}
uses: docker/login-action@v3
with:
registry: ${{ inputs.registry }}
username: ${{ github.actor }}
password: ${{ secrets.token }}

- name: Do some shell magic
if: ${{ github.event_name != 'pull_request'}}
shell: bash
id: sh_settings
env:
DO_TAG: ${{inputs.do_tag}}
run: |
if [ $DO_TAG = 'YES' ]; then
echo "tag=lite-${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
else
echo "tag=lite" >> $GITHUB_OUTPUT
fi
echo "repository=${GITHUB_REPOSITORY@L}" >> $GITHUB_OUTPUT
- name: '[LITE] Build and push container image'
id: push
uses: docker/build-push-action@v6
with:
cache-from: ${{inputs.registry}}/${{github.repository}}/tools:${{ steps.sh_settings.outputs.tag }}
file: docker/Dockerfile.lite
context: docker
tags: ${{inputs.registry}}/${{ steps.sh_settings.outputs.repository }}/tools:${{ steps.sh_settings.outputs.tag }}
platforms: linux/amd64,linux/arm64
push: ${{github.event_name != 'pull_request'}}

- name: '[LITE] Generate artifact attestation'
if: ${{github.event_name != 'pull_request'}}
uses: actions/attest-build-provenance@v1
with:
subject-name: ${{ inputs.registry }}//${{ steps.sh_settings.outputs.repository }}
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true

26 changes: 26 additions & 0 deletions .github/workflows/tools-lite-container-latest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Tools [LITE] Container - Publish

on:
workflow_dispatch:
push:
branches:
- main
paths:
- 'docker/**'
- '.github/**'

jobs:
publish_latest:
name: Push latest [LITE] container image to GitHub Packages
permissions:
contents: read
packages: write
attestations: write
id-token: write
uses: .github/workflows/shared-steps.yml
with:
registry: ghcr.io
do_tag: 'NOPE'
secrets:
token: ${{ secrets.GITHUB_TOKEN }}

15 changes: 15 additions & 0 deletions .github/workflows/tools-lite-container-pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: '[LITE] Tools Container - PR Validation'

on:
workflow_dispatch:
pull_request:
paths:
- 'docker/**'

jobs:
pr_validation:
name: '[LITE] PR Validation'
uses: .github/workflows/shared-steps.yml
with:
registry: ghcr.io
do_tag: 'NOPE'
22 changes: 22 additions & 0 deletions .github/workflows/tools-lite-container-tag.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: '[LITE] Tools Container - Publish Tag'

on:
workflow_dispatch:
release:
types:
- published

jobs:
publish_latest:
name: '[LITE] Push tagged container image to GitHub Packages'
permissions:
contents: read
packages: write
attestations: write
id-token: write
uses: .github/workflows/shared-steps.yml
with:
registry: ghcr.io
do_tag: 'YES'
secrets:
token: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit 0f5cec2

Please sign in to comment.