Skip to content

Commit

Permalink
Added tag based image build workflow for gh actions (#107)
Browse files Browse the repository at this point in the history
* Added tag based image build workflow for gh actions

* updated job name
  • Loading branch information
farhanW3 authored Sep 8, 2023
1 parent 7ff1cf5 commit 8c356b7
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/tagBasedImageBuild.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Tag Based Image Build

on:
create: # This listens to create events, which includes tag creations

jobs:
buildImageForNewTag:
if: startsWith(github.ref, 'refs/tags/') # Only run this job when a tag is created
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Verify tag is on main branch
run: |
TAG_COMMIT=$(git rev-list -n 1 ${{ github.ref }})
MAIN_BRANCH_COMMIT=$(git rev-list -n 1 main)
if [ "$TAG_COMMIT" != "$MAIN_BRANCH_COMMIT" ]; then
echo "Tag is not on the main branch, aborting!"
exit 1
fi
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build and Push Docker Image
uses: docker/build-push-action@v2
with:
context: .
target: prod
platforms: linux/amd64,linux/arm64
push: true
tags: thirdweb/web3-api:${{ github.ref_name }} # Set the docker tag to the Git tag name

0 comments on commit 8c356b7

Please sign in to comment.