Skip to content

Commit

Permalink
Have github action run on versions
Browse files Browse the repository at this point in the history
  • Loading branch information
galt-tr committed Feb 21, 2025
1 parent b9f6aeb commit a8ccb6e
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,38 @@ name: Build and Push Docker Image
# Trigger the workflow on push or pull request to the main branch
on:
push:
tags:
- 'v*'
branches:
- master
pull_request:
branches:
- master

jobs:
build-and-push:
# Get version tag
get_tag:
runs-on: ubuntu-latest
steps:
- name: Determine deployment tag
id: deployment_tag
run: |
if [[ '${{ github.ref_type }}' == 'tag' ]]; then
export tag=${{ github.ref_name }}
echo "version tag is $tag"
echo "id=$tag" >> $GITHUB_OUTPUT
else
export tag=${{ github.sha }}
echo "version tag is $tag"
echo "id=$tag" >> $GITHUB_OUTPUT
fi
outputs:
deployment_tag: ${{ steps.deployment_tag.outputs.id }}

jobs:
build-and-push:
needs: [ get_tag ]
runs-on: ubuntu-latest
steps:
# Step 1: Check out the repository code
- name: Checkout code
Expand All @@ -38,7 +60,7 @@ jobs:
push: ${{ github.event_name != 'pull_request' }} # Only push on push events, not PRs
tags: |
docker.io/bsvb/truth-machine-demo:${{ github.sha }}
docker.io/bsvb/truth-machine:latest
docker.io/bsvb/truth-machine: ${{ needs.get_tag.outputs.deployment_tag }}
# Step 5: Build and push the backend Docker image
- name: Build and push frontend Docker image
Expand Down

0 comments on commit a8ccb6e

Please sign in to comment.