65 lines
1.6 KiB
YAML
65 lines
1.6 KiB
YAML
name: Publish Docker image
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- master
|
|
release:
|
|
types: [published]
|
|
|
|
jobs:
|
|
push_to_registry:
|
|
name: Push Docker image to Docker Hub
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
packages: write
|
|
contents: read
|
|
attestations: write
|
|
id-token: write
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v2
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v2
|
|
|
|
- name: Login to Docker Hub
|
|
uses: docker/login-action@v3
|
|
with:
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
|
|
- name: Extract version from shard.yml
|
|
id: extract_version
|
|
run: |
|
|
VERSION=$(grep '^version:' shard.yml | cut -d ' ' -f 2)
|
|
echo "RELEASE_TAG=$VERSION" >> $GITHUB_ENV
|
|
|
|
- name: Set tags
|
|
id: set_tags
|
|
run: |
|
|
if [[ "${{ github.event_name }}" == "release" ]]; then
|
|
echo "TAGS=latest,${{ env.RELEASE_TAG }}" >> $GITHUB_ENV
|
|
else
|
|
echo "TAGS=latest" >> $GITHUB_ENV
|
|
fi
|
|
|
|
- name: Build and push image
|
|
id: push
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: .
|
|
push: true
|
|
platforms: linux/amd64,linux/arm64
|
|
tags: sjdonado/bit:${{ env.TAGS }}
|
|
|
|
- name: Attest
|
|
uses: actions/attest-build-provenance@v1
|
|
id: attest
|
|
with:
|
|
subject-name: sjdonado/bit
|
|
subject-digest: ${{ steps.push.outputs.digest }}
|