Merge rust and docker workflows
Some checks failed
Publish / rust (push) Successful in 5m9s
Publish / docker (push) Failing after 14s

This commit is contained in:
Jeff 2024-07-18 07:06:56 -04:00
parent de0abd956d
commit ac358082cb
2 changed files with 26 additions and 74 deletions

View File

@ -1,45 +1,44 @@
name: Docker name: Publish
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
on: on:
push: push:
branches: [ "main" ] branches:
- main
pull_request: pull_request:
branches: [ "main" ] branches:
- main
env: env:
# Use docker.io for Docker Hub if empty
REGISTRY: git.jeffa.io REGISTRY: git.jeffa.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ gitea.repository }} IMAGE_NAME: ${{ gitea.repository }}
jobs: jobs:
build: rust:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Rust
uses: actions-rs/toolchain@v1
- name: Run cargo clippy
run: cargo clippy -- -D warnings
- name: Check for errors
run: |
if [ "$?" -ne 0 ]; then
echo "Check failed"
exit 1
fi
docker:
runs-on: ubuntu-latest
needs: rust
permissions: permissions:
contents: read contents: read
packages: write packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write id-token: write
steps: steps:
- name: Checkout repository
uses: actions/checkout@v4
# Install the cosign tool except on PR
# https://github.com/sigstore/cosign-installer
- name: Install cosign
if: github.event_name != 'pull_request'
uses: sigstore/cosign-installer@59acb6260d9c0ba8f4a2f9d9b48431a222b68e20 #v3.5.0
with:
cosign-release: 'v2.2.4'
# Set up BuildKit Docker container builder to be able to build # Set up BuildKit Docker container builder to be able to build
# multi-platform images and export cache # multi-platform images and export cache
# https://github.com/docker/setup-buildx-action # https://github.com/docker/setup-buildx-action
@ -76,18 +75,3 @@ jobs:
labels: ${{ steps.meta.outputs.labels }} labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha cache-from: type=gha
cache-to: type=gha,mode=max cache-to: type=gha,mode=max
# Sign the resulting Docker image digest except on PRs.
# This will only write to the public Rekor transparency log when the Docker
# repository is public to avoid leaking data. If you would like to publish
# transparency data even for private images, pass --force to cosign below.
# https://github.com/sigstore/cosign
- name: Sign the published Docker image
if: ${{ github.event_name != 'pull_request' }}
env:
# https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable
TAGS: ${{ steps.meta.outputs.tags }}
DIGEST: ${{ steps.build-and-push.outputs.digest }}
# This step uses the identity token to provision an ephemeral certificate
# against the sigstore community Fulcio instance.
run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}

View File

@ -1,32 +0,0 @@
name: Rust
on:
push:
branches:
- dev
- main
pull_request:
branches:
- dev
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Rust
uses: actions-rs/toolchain@v1
- name: Run cargo clippy
run: cargo clippy -- -D warnings
- name: Check for errors
run: |
if [ "$?" -ne 0 ]; then
echo "Check failed"
exit 1
fi