This repository has been archived by the owner on Sep 3, 2024. It is now read-only.
rumble-image-publish #384
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
name: rumble-image-publish | |
on: | |
push: | |
branches: | |
- main | |
schedule: | |
- cron: '0 8 * * *' # 8am UTC — 2 hours before daily scan | |
workflow_dispatch: {} | |
env: | |
REF: "ghcr.io/chainguard-dev/rumble:latest" | |
REGISTRY_USERNAME: ${{ github.repository_owner }} | |
REGISTRY_PASSWORD: ${{ github.token }} | |
COSIGN_EXPERIMENTAL: "true" | |
CHAINGUARD_GITHUB_EVENT_NAME: "schedule" | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
id-token: write # needed for GitHub OIDC Token **not production ready** | |
steps: | |
- name: Checkout source code | |
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 | |
- uses: actions/setup-go@v4 | |
with: | |
go-version: '1.20' | |
- name: Run Go tests | |
run: | | |
set -x | |
go test -v ./... | |
- name: Install Cosign | |
uses: sigstore/cosign-installer@9becc617647dfa20ae7b1151972e9b3a2c338a2b # v2.8.1 | |
- name: Login to registry | |
id: login | |
run: | | |
set -x | |
export DOCKER_CONFIG="$(mktemp -d)" | |
cosign login ghcr.io -u "${REGISTRY_USERNAME}" -p "${REGISTRY_PASSWORD}" | |
echo "docker-config=${DOCKER_CONFIG}" >> $GITHUB_OUTPUT | |
- name: Publish image | |
env: | |
DOCKER_CONFIG: ${{ steps.login.outputs.docker-config }} | |
run: | | |
set -x | |
./scripts/publish.sh | |
- name: Attestationception! | |
env: | |
DOCKER_CONFIG: ${{ steps.login.outputs.docker-config }} | |
run: | | |
set -x | |
env > github.env | |
echo "DOCKER_CONFIG=/config" >> github.env | |
for scanner in "grype" "trivy"; do | |
docker run --rm -v "${DOCKER_CONFIG}":/config \ | |
--env-file github.env \ | |
"${REF}" \ | |
-image "${REF}" \ | |
-scanner "${scanner}" \ | |
-attest \ | |
-invocation-uri "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" \ | |
-invocation-event-id "${{ github.run_id }}" \ | |
-invocation-builder-id "${{ github.workflow }}" | |
done | |
# Slack notification if build failing | |
- uses: slackapi/slack-github-action@007b2c3c751a190b6f0f040e47ed024deaa72844 # v1.23.0 | |
if: failure() | |
id: slack | |
with: | |
payload: '{"text": "[rumble-image-publish] failed: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"}' | |
env: | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} | |
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK |