Build docker image in GitHub actions #5
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
name: Test Backend - Build & Push | ||
on: | ||
push: | ||
branches: [ "build-docker-image-in-github-actions" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
jobs: | ||
build-and-push: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out repository | ||
uses: actions/checkout@v4 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
- name: Login to Docker Hub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ vars.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
- name: Git Hash | ||
run: echo "GIT_HASH=$(echo ${{ github.sha }} | cut -c1-7 | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV | ||
- name: Build and push | ||
uses: docker/build-push-action@v6 | ||
with: | ||
context: "./server" | ||
platforms: | ||
- linux/arm64 | ||
Check failure on line 32 in .github/workflows/test.yml
|
||
push: true | ||
tags: | ||
- acmucsd/hackathon-portal-api:${{ env.GIT_HASH }} | ||
- acmucsd/hackathon-portal-api:latest |