Skip to content

npm i

npm i #12

Workflow file for this run

# build.yml
name: Build & Push Docker Image to GHCR
on:
push: # Triggers the workflow on push events
branches:
- main
workflow_dispatch: # Allows manual triggering of the workflow from the GitHub Actions tab
env:
DOCKERFILE_PATH: ./server/Dockerfile # πŸ‘ˆ Update this to wherever your Dockerfile is within your repository
jobs:
build-push:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository πŸ‘€
uses: actions/checkout@v4 # Clones the repo for the workflow to access
- name: Set up QEMU for cross-platform builds
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry πŸ”
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GHCR_PAT }}
- name: Convert owner and repo to lowercase
id: vars
run: |
echo "repo_owner=$(echo '${{ github.repository_owner }}' | tr '[:upper:]' '[:lower:]')" >> "$GITHUB_OUTPUT"
echo "repo_name=$(echo '${{ github.event.repository.name }}' | tr '[:upper:]' '[:lower:]')" >> "$GITHUB_OUTPUT"
# Builds and pushes the Docker image to GitHub Container Registry
# Uses the latest tag and the commit SHA as a version tag
- name: Build and Push Multi-Arch Image πŸ‹
uses: docker/build-push-action@v5
with:
context: .
file: ${{ env.DOCKERFILE_PATH }}
platforms: linux/amd64,linux/arm64
push: true
tags: |
ghcr.io/${{ steps.vars.outputs.repo_owner }}/${{ steps.vars.outputs.repo_name }}:latest
ghcr.io/${{ steps.vars.outputs.repo_owner }}/${{ steps.vars.outputs.repo_name }}:${{ github.sha }}