read HEAD tag and apply in docker/metadata-action #285
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
on: [push] | |
name: CI | |
jobs: | |
fossa-scan: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: fossas/fossa-action@main # Use a specific version if locking is preferred | |
with: | |
api-key: ${{secrets.FOSSA_API_KEY}} | |
test: | |
name: Build, test (x86) | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
- uses: Swatinem/rust-cache@v2 | |
- uses: actions-rs/cargo@v1 | |
with: | |
command: test | |
args: -- --test-threads=1 | |
- uses: actions-rs/cargo@v1 | |
with: | |
command: build | |
args: --release --all-features | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: crd_gen | |
path: target/release/crd_gen | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: databricks_kube | |
path: target/release/databricks_kube | |
publish_image: | |
name: Docker | |
runs-on: ubuntu-latest | |
needs: test | |
if: github.ref == 'refs/heads/master' | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Log in to the Container registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- id: tag | |
name: Read HEAD tag | |
run: echo "tag=$(git tag --points-at HEAD | head -1)" >> $GITHUB_OUTPUT | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ghcr.io/${{ github.repository }} | |
tags: | | |
type=raw,value=latest | |
type=raw,value=${{ github.ref_name }} | |
type=raw,value=${{ steps.tag.outputs.tag }} | |
- uses: actions/download-artifact@v4 | |
with: | |
name: crd_gen | |
path: target/release/crd_gen | |
- uses: actions/download-artifact@v4 | |
with: | |
name: databricks_kube | |
path: target/release/databricks_kube | |
- name: Build and push | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} |