Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: avoid localhost namespaced images in build-push workflow #31

Merged
merged 1 commit into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/paths-filter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ image:
builder:
- 'Dockerfile'
- '.github/workflows/pr.yml'
ci:
- '.github/workflows/ci.yml'
- '.github/workflows/build-push.yml'
29 changes: 22 additions & 7 deletions .github/workflows/build-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,24 @@ jobs:
with:
submodules: 'true'

- name: Generate metadata
id: metadata
run: |
#!/bin/bash
set -xeo pipefail

image="${{ inputs.registry }}/${{ inputs.image }}"
tags=""

for tag in ${{ inputs.tags }}
do
tags+="${image}:${tag} "
done
tags=$(echo $tags | sed 's/\s+$//')

echo "image=$image" >> "$GITHUB_OUTPUT"
echo "tags=$tags" >> "$GITHUB_OUTPUT"

- name: Inject ostree version
run: |
#!/bin/bash
Expand All @@ -45,8 +63,7 @@ jobs:
id: build
uses: redhat-actions/buildah-build@7a95fa7ee0f02d552a32753e7414641a04307056 # v2.13
with:
image: ${{ inputs.image }}
tags: ${{ inputs.tags }}
tags: ${{ steps.metadata.outputs.tags }}
containerfiles: |
Dockerfile
oci: 'true'
Expand All @@ -61,9 +78,7 @@ jobs:
id: push
uses: redhat-actions/push-to-registry@5ed88d269cf581ea9ef6dd6806d01562096bee9c # v2.8
with:
image: ${{ steps.build.outputs.image }}
tags: ${{ steps.build.outputs.tags }}
registry: ${{ inputs.registry }}
tags: ${{ steps.metadata.outputs.tags }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

Expand All @@ -78,7 +93,7 @@ jobs:
cosign sign --yes --key env://COSIGN_PRIVATE_KEY
--registry-password='${{ secrets.GITHUB_TOKEN }}'
--registry-username='${{ github.actor }}'
${{ inputs.registry }}/${{ steps.build.outputs.image }}@${{ steps.push.outputs.digest }}
${{ steps.metadata.outputs.image }}@${{ steps.push.outputs.digest }}

- name: Start podman daemon
run: systemctl --user start podman.socket
Expand All @@ -102,7 +117,7 @@ jobs:
--registry-password='${{ secrets.GITHUB_TOKEN }}'
--registry-username='${{ github.actor }}'
--predicate='${{ inputs.image }}-${{ inputs.version }}.syft.json'
${{ inputs.registry }}/${{ steps.build.outputs.image }}@${{ steps.push.outputs.digest }}
${{ steps.metadata.outputs.image }}@${{ steps.push.outputs.digest }}

- name: Scan SBOM with Grype
uses: anchore/scan-action@3343887d815d7b07465f6fdcd395bd66508d486a # v3.6.4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
gen-metadata:
name: Generate metadata
needs: check-changes
if: ${{ needs.check-changes.outputs.image == 'true' }}
if: ${{ needs.check-changes.outputs.image == 'true' || needs.check-changes.outputs.ci == 'true' }}
runs-on: ubuntu-24.04
outputs:
tags: ${{ steps.metadata.outputs.tags }}
Expand Down