Merge pull request #76 from joshuar/dependabot/github_actions/google-… #29
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright (c) 2023 Joshua Rich <[email protected]> | |
# | |
# This software is released under the MIT License. | |
# https://opensource.org/licenses/MIT | |
name: build-container | |
env: | |
REGISTRY: ghcr.io | |
REGISTRY_USER: ${{ github.actor }} | |
REGISTRY_PASSWORD: ${{ secrets.GITHUB_TOKEN }} | |
IMAGE: ${{ github.repository }} | |
on: | |
release: | |
types: [ created ] | |
push: | |
branches: | |
- main | |
permissions: | |
contents: read | |
packages: write | |
jobs: | |
build-push-image: | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v4 | |
- name: Install/Cache dependencies | |
uses: awalsh128/cache-apt-pkgs-action@latest | |
with: | |
packages: qemu-user-static | |
- name: Update VERSION | |
id: update_version | |
shell: sh | |
run: cd internal/agent/config && printf %s $(git tag | tail -1) > VERSION | |
- name: Build container image | |
id: build_image | |
uses: redhat-actions/buildah-build@v2 | |
with: | |
archs: amd64 | |
# context: build/package | |
image: ${{ env.IMAGE }} | |
tags: latest ${{ github.sha }} | |
containerfiles: Dockerfile | |
layers: false | |
oci: true | |
- name: Push to Container Registry | |
id: push_image | |
uses: redhat-actions/push-to-registry@v2 | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
with: | |
username: ${{ env.REGISTRY_USER }} | |
password: ${{ env.REGISTRY_PASSWORD }} | |
image: ${{ env.IMAGE }} | |
registry: ${{ env.REGISTRY }} | |
tags: ${{ steps.build_image.outputs.tags }} | |
extra-args: | | |
--disable-content-trust | |
- name: Login to Container Registry | |
uses: redhat-actions/podman-login@v1 | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ env.REGISTRY_USER }} | |
password: ${{ env.REGISTRY_PASSWORD }} | |
- name: Check and install cosign | |
uses: sigstore/[email protected] | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
with: | |
cosign-release: 'v2.2.2' | |
- name: Sign image with a key | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
run: | | |
cosign --verbose=true sign --yes --key cosign.key \ | |
-a "repo=${{ github.repository }}" \ | |
-a "ref=${{ github.ref }}" \ | |
${{ env.REGISTRY }}/${{ env.IMAGE }}@${{ steps.push_image.outputs.digest }} | |
env: | |
COSIGN_PASSWORD: ${{ secrets.COSIGN_PWD }} |