Merge pull request #20 from SpokaneTech/event_card_update #28
Workflow file for this run
This file contains hidden or 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: Build and Push Docker Image | |
| on: | |
| release: | |
| types: [created] | |
| workflow_dispatch: | |
| push: | |
| tags: | |
| - '[0-9]+.[0-9]+.[0-9]+-dev' | |
| - '[0-9]+.[0-9]+.[0-9]+-dev.[0-9]+' | |
| - '[0-9]+.[0-9]+.[0-9]+-rc' | |
| - '[0-9]+.[0-9]+.[0-9]+-rc.[0-9]+' | |
| - '[0-9]+.[0-9]+.[0-9]+' | |
| env: | |
| REGISTRY: ghcr.io | |
| IMAGE_NAME: ${{ github.repository }} | |
| jobs: | |
| build-and-push: | |
| name: Build and Push Docker Image | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract tag name | |
| id: vars | |
| run: | | |
| TAG_NAME=${GITHUB_REF#refs/tags/} | |
| IMAGE_NAME_LOWER=$(echo "${GITHUB_REPOSITORY}" | tr '[:upper:]' '[:lower:]') | |
| echo "tag=${TAG_NAME}" >> $GITHUB_OUTPUT | |
| echo "image_name=${IMAGE_NAME_LOWER}" >> $GITHUB_OUTPUT | |
| if [[ "$TAG_NAME" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | |
| echo "latest=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "latest=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| file: ./src/docker/Dockerfile | |
| push: true | |
| build-args: | | |
| IMAGE_TAG=${{ steps.vars.outputs.tag }} | |
| tags: | | |
| ghcr.io/${{ steps.vars.outputs.image_name }}:${{ steps.vars.outputs.tag }} | |
| ${{ steps.vars.outputs.latest == 'true' && format('ghcr.io/{0}:latest', steps.vars.outputs.image_name) || '' }} | |
| labels: | | |
| org.opencontainers.image.source=${{ github.repositoryUrl }} | |
| org.opencontainers.image.version=${{ steps.vars.outputs.tag }} | |
| org.opencontainers.image.created=${{ github.event.head_commit.timestamp || github.event.release.published_at || github.event.repository.updated_at }} | |
| org.opencontainers.image.revision=${{ github.sha }} | |
| org.opencontainers.image.title=${{ github.repository }} | |
| - name: Confirm tags pushed | |
| run: | | |
| echo "Published ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.vars.outputs.tag }}" | |
| if [ "${{ steps.vars.outputs.latest }}" = "true" ]; then | |
| echo "Also tagged as :latest" | |
| fi |