Skip to content

Commit

Permalink
Make reg an input + unique run id
Browse files Browse the repository at this point in the history
  • Loading branch information
efrecon committed Feb 9, 2024
1 parent f11a502 commit a04f648
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
27 changes: 21 additions & 6 deletions .github/workflows/_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ on:
required: false
type: string
default: 'linux/amd64,linux/arm64'
registry:
description: 'Registry to push to'
required: false
type: string
default: 'ghcr.io'
secrets:
username:
description: 'username at registry'
Expand All @@ -36,21 +41,30 @@ on:
required: true

env:
REGISTRY_IMAGE: ${{ inputs.image }}
REGISTRY_IMAGE: ${{inputs.registry }}/${{ inputs.image }}

jobs:
convert:
runs-on: ${{ inputs.runs-on }}
outputs:
platforms: ${{ steps.convert.outputs.platforms }}
run-id: ${{ steps.run-id.outputs.run-id }}
steps:
-
name: Convert Platforms
id: convert
run: |
platforms=${{ inputs.platforms }}
inside=$(printf %s\\n "$platforms" | sed -E -e 's/,/\", \"/g' -e 's/\" +/\"/g' -e 's/ +\"/\"/g')
printf 'platforms=["%s"]' "$inside" >> $GITHUB_OUTPUT
printf 'platforms=["%s"]\n' "$inside" >> $GITHUB_OUTPUT
-
name: Generate artifact name
id: run-id
run: |
random_string() {
LC_ALL=C tr -dc 'a-zA-Z0-9' < /dev/urandom | head -c "${1:-12}"
}
printf 'run-id=%s\n' "$(random_string)" >> $GITHUB_OUTPUT
build:
runs-on: ${{ inputs.runs-on }}
Expand Down Expand Up @@ -86,7 +100,7 @@ jobs:
name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
registry: ${{ inputs.registry }}
username: ${{ secrets.username }}
password: ${{ secrets.password }}
-
Expand All @@ -109,7 +123,7 @@ jobs:
name: Upload digest
uses: actions/upload-artifact@v4
with:
name: digests-${{ env.PLATFORM_PAIR }}
name: digests-${{ needs.convert.outputs.run-id }}-${{ env.PLATFORM_PAIR }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1
Expand All @@ -118,13 +132,14 @@ jobs:
runs-on: ubuntu-latest
needs:
- build
- convert
steps:
-
name: Download digests
uses: actions/download-artifact@v4
with:
path: /tmp/digests
pattern: digests-*
pattern: digests-${{ needs.convert.outputs.run-id }}-*
merge-multiple: true
-
name: Set up Docker Buildx
Expand All @@ -139,7 +154,7 @@ jobs:
name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
registry: ${{ inputs.registry }}
username: ${{ secrets.username }}
password: ${{ secrets.password }}
-
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
build-base:
uses: ./.github/workflows/_build.yml
with:
image: ghcr.io/${{ github.actor }}/runner-krunvm-base
image: ${{ github.actor }}/runner-krunvm-base
file: Dockerfile.base
secrets:
username: ${{ github.actor }}
Expand All @@ -21,7 +21,7 @@ jobs:
- build-base
uses: ./.github/workflows/_build.yml
with:
image: ghcr.io/${{ github.actor }}/runner-krunvm
image: ${{ github.actor }}/runner-krunvm
file: Dockerfile
secrets:
username: ${{ github.actor }}
Expand Down

0 comments on commit a04f648

Please sign in to comment.