Deploy Images to GHCR #7
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: Deploy Images to GHCR | |
on: | |
workflow_run: | |
workflows: [ "CI fmt clippy and test" ] | |
types: | |
- completed | |
push: | |
branches: | |
- main # Trigger only on push to main branch | |
tags: # Trigger on new tags | |
- 'v*' | |
jobs: | |
push-store-image: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: 'Checkout GitHub Action' | |
uses: actions/checkout@main | |
- name: 'Set up Docker Buildx' | |
uses: docker/setup-buildx-action@v1 | |
- name: 'Login to GitHub Container Registry' | |
uses: docker/login-action@v1 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: 'Extract short hash' | |
id: vars | |
run: echo "SHORT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_ENV # This sets the SHORT_SHA environment variable | |
- name: 'Set Docker tag' | |
id: docker_tag | |
run: | | |
if [[ "${{ github.ref }}" == refs/tags/* ]]; then | |
TAG_NAME=${{ github.ref }} | |
TAG_NAME=${TAG_NAME##*/} | |
echo "DOCKER_TAG=${TAG_NAME}" >> $GITHUB_ENV | |
else | |
echo "DOCKER_TAG=${{ env.SHORT_SHA }}" >> $GITHUB_ENV | |
fi | |
- name: Build and push pbs | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
push: true | |
tags: ghcr.io/commit-boost/commit-boost-client/pbs:${{ env.DOCKER_TAG }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
file: docker/pbs.Dockerfile | |
- name: Build and push signer | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
push: true | |
tags: ghcr.io/commit-boost/commit-boost-client/signer:${{ env.DOCKER_TAG }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
file: docker/signer.Dockerfile |