-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added tag based image build workflow for gh actions (#107)
* Added tag based image build workflow for gh actions * updated job name
- Loading branch information
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
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
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 |