Update sbt-ci-release to 1.9.2 #373
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: Docker | |
on: | |
push: | |
branches: | |
- main | |
tags: | |
- 'v*' | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
build-and-push-image: | |
runs-on: blacksmith-2vcpu-ubuntu-2204 | |
permissions: | |
id-token: write | |
attestations: write | |
contents: read | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
- name: Coursier cache | |
uses: useblacksmith/coursier-cache-action@v6 | |
- uses: taiki-e/install-action@parse-changelog | |
- name: Set build timestamp | |
run: echo "SOURCE_DATE_EPOCH=$(date -d $(parse-changelog CHANGELOG.md -t | rev | cut -d' ' -f1 | rev) '+%s')" >> "$GITHUB_ENV" | |
- uses: coursier/setup-action@v1 | |
with: | |
jvm: zulu:11.0.10 | |
apps: sbt scala | |
- name: Compile and prepare Docker configuration | |
run: sbt Docker/stage | |
env: | |
GITHUB_TOKEN: ${{ secrets.GH_PERSONAL_TOKEN }} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Log in to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/[email protected] | |
with: | |
images: michaelmior/jsonoid-discovery | |
tags: | | |
# semver tags | |
type=semver,pattern={{version}} | |
type=semver,pattern={{major}}.{{minor}} | |
# set latest tag for default branch | |
type=raw,value=latest,enable={{is_default_branch}} | |
- name: Build image | |
uses: docker/build-push-action@v6 | |
env: | |
DOCKER_BUILD_NO_SUMMARY: true | |
with: | |
context: ./target/docker/stage | |
load: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
push: false | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
- name: Test image | |
env: | |
DOCKER_TAG: ${{ steps.meta.outputs.tags }} | |
run: (echo '{}' | docker run --rm -i $(echo "$DOCKER_TAG" | head -1) > /dev/null) && echo "OK" | |
- name: Build and push image | |
uses: docker/build-push-action@v6 | |
id: push | |
with: | |
context: ./target/docker/stage | |
sbom: true | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
- name: Attest | |
uses: actions/attest-build-provenance@v2 | |
id: attest | |
with: | |
subject-name: index.docker.io/michaelmior/jsonoid-discovery | |
subject-digest: ${{ steps.push.outputs.digest }} | |
push-to-registry: true |