-
Notifications
You must be signed in to change notification settings - Fork 0
51 lines (42 loc) · 1.81 KB
/
build.yml
File metadata and controls
51 lines (42 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# 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 }}