|
| 1 | +name: Release falco_plugin (OCI) |
| 2 | + |
| 3 | +on: |
| 4 | + release: |
| 5 | + types: [published] |
| 6 | + |
| 7 | +permissions: |
| 8 | + contents: read # Default token to read |
| 9 | + |
| 10 | + |
| 11 | +jobs: |
| 12 | + build: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + permissions: |
| 15 | + contents: read |
| 16 | + packages: write |
| 17 | + id-token: write |
| 18 | + |
| 19 | + steps: |
| 20 | + - name: harden runner |
| 21 | + uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2 |
| 22 | + with: |
| 23 | + egress-policy: audit |
| 24 | + |
| 25 | + - name: install cosign |
| 26 | + uses: sigstore/cosign-installer@4959ce089c160fddf62f7b42464195ba1a56d382 # v3.6.0 |
| 27 | + |
| 28 | + - name: checkout repository |
| 29 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 |
| 30 | + with: |
| 31 | + persist-credentials: false |
| 32 | + |
| 33 | + - name: Set up QEMU |
| 34 | + uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 #v3.6 |
| 35 | + |
| 36 | + - name: docker setup buildx |
| 37 | + uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # v3 |
| 38 | + |
| 39 | + - name: docker login ghcr.io |
| 40 | + if: github.event_name != 'pull_request' |
| 41 | + uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3 |
| 42 | + with: |
| 43 | + registry: ghcr.io |
| 44 | + username: "${{ github.actor }}" |
| 45 | + password: '${{ github.token }}' |
| 46 | + |
| 47 | + - name: extract metadata |
| 48 | + id: meta |
| 49 | + working-directory: ${{ env.CONTAINERFILE_DIR }} |
| 50 | + run: | |
| 51 | + REPO_NAME=${{ github.event.repository.name }} |
| 52 | + FULL_IMAGE_NAME=ghcr.io/${{ github.repository_owner }}/edera_falco_plugin |
| 53 | + echo "full-image-name=${FULL_IMAGE_NAME,,}" >> $GITHUB_OUTPUT |
| 54 | +
|
| 55 | + if [[ "${{ github.event_name }}" == "pull_request" ]]; then |
| 56 | + TAGS="${FULL_IMAGE_NAME,,}:pr-${{ github.event.number }}" |
| 57 | + else |
| 58 | + TAGS="${FULL_IMAGE_NAME,,}:${{ github.sha }},${FULL_IMAGE_NAME,,}:latest" |
| 59 | + fi |
| 60 | + echo "tags=${TAGS}" >> $GITHUB_OUTPUT |
| 61 | +
|
| 62 | + - name: build and push Docker image |
| 63 | + uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6 |
| 64 | + id: push |
| 65 | + with: |
| 66 | + context: . |
| 67 | + file: ./Containerfile |
| 68 | + platforms: "linux/amd64" |
| 69 | + push: ${{ github.event_name != 'pull_request' }} |
| 70 | + tags: ${{ steps.meta.outputs.tags }} |
| 71 | + cache-from: type=gha |
| 72 | + cache-to: type=gha,mode=max |
| 73 | + labels: | |
| 74 | + org.opencontainers.image.title=${{ steps.meta.outputs.target-name }} |
| 75 | + org.opencontainers.image.source=${{ github.event.repository.html_url }} |
| 76 | + org.opencontainers.image.revision=${{ github.sha }} |
| 77 | +
|
| 78 | + - name: cosign all images |
| 79 | + if: github.event_name != 'pull_request' |
| 80 | + shell: bash |
| 81 | + run: | |
| 82 | + IFS=',' read -ra TAGS <<< '${{ steps.meta.outputs.tags }}' |
| 83 | + for tag in "${TAGS[@]}"; do |
| 84 | + pullstring="${tag}@${{ steps.push.outputs.digest }}" |
| 85 | + echo "Signing ${pullstring}" |
| 86 | + cosign sign --yes "${pullstring}" |
| 87 | + done |
| 88 | + env: |
| 89 | + DIGEST: '${{ steps.push.outputs.digest }}' |
| 90 | + COSIGN_EXPERIMENTAL: 'true' |
0 commit comments