Skip to content

Commit 8c356b7

Browse files
authored
Added tag based image build workflow for gh actions (#107)
* Added tag based image build workflow for gh actions * updated job name
1 parent 7ff1cf5 commit 8c356b7

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Tag Based Image Build
2+
3+
on:
4+
create: # This listens to create events, which includes tag creations
5+
6+
jobs:
7+
buildImageForNewTag:
8+
if: startsWith(github.ref, 'refs/tags/') # Only run this job when a tag is created
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Checkout code
13+
uses: actions/checkout@v2
14+
15+
- name: Verify tag is on main branch
16+
run: |
17+
TAG_COMMIT=$(git rev-list -n 1 ${{ github.ref }})
18+
MAIN_BRANCH_COMMIT=$(git rev-list -n 1 main)
19+
if [ "$TAG_COMMIT" != "$MAIN_BRANCH_COMMIT" ]; then
20+
echo "Tag is not on the main branch, aborting!"
21+
exit 1
22+
fi
23+
24+
- name: Set up Docker Buildx
25+
uses: docker/setup-buildx-action@v1
26+
27+
- name: Login to DockerHub
28+
uses: docker/login-action@v1
29+
with:
30+
username: ${{ secrets.DOCKER_USERNAME }}
31+
password: ${{ secrets.DOCKER_PASSWORD }}
32+
33+
- name: Build and Push Docker Image
34+
uses: docker/build-push-action@v2
35+
with:
36+
context: .
37+
target: prod
38+
platforms: linux/amd64,linux/arm64
39+
push: true
40+
tags: thirdweb/web3-api:${{ github.ref_name }} # Set the docker tag to the Git tag name

0 commit comments

Comments
 (0)