Skip to content

Commit 1678083

Browse files
committed
Add publish action
1 parent 087367d commit 1678083

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed

.github/workflows/publish.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Build and Publish Docker Image
2+
3+
on:
4+
push:
5+
pull_request:
6+
workflow_dispatch:
7+
8+
env:
9+
REGISTRY: ghcr.io
10+
IMAGE_NAME: discourse
11+
RELEASE_BRANCH: refs/heads/master
12+
SHOULD_PUSH_IMAGE: ${{ (github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/dev')) || github.event_name == 'workflow_dispatch' }}
13+
14+
jobs:
15+
build-publish-amd64:
16+
name: Build and Publish Docker Image (amd64)
17+
runs-on: ubuntu-latest
18+
19+
permissions:
20+
contents: read
21+
packages: write
22+
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@v5
26+
27+
- name: Set up QEMU for Docker
28+
uses: docker/setup-qemu-action@v3
29+
30+
- name: Set up Docker Buildx
31+
uses: docker/setup-buildx-action@v3
32+
33+
- name: Log into the container registry
34+
if: ${{ env.SHOULD_PUSH_IMAGE == 'true' }}
35+
uses: docker/login-action@v3
36+
with:
37+
registry: ${{ env.REGISTRY }}
38+
username: ${{ github.actor }}
39+
password: ${{ secrets.GITHUB_TOKEN }}
40+
41+
- name: Extract Docker metadata
42+
id: meta
43+
uses: docker/metadata-action@v5
44+
with:
45+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
46+
tags: |
47+
type=raw,value=latest,enable=${{ github.ref == env.RELEASE_BRANCH }}
48+
type=raw,value=edge,enable=${{ github.ref == 'refs/heads/dev' }}
49+
type=sha
50+
51+
- name: Prepare discourse dependencies
52+
run: ./build.sh
53+
54+
- name: Build and push Docker image
55+
id: build-and-push
56+
uses: docker/build-push-action@v6
57+
with:
58+
platforms: linux/amd64
59+
push: ${{ env.SHOULD_PUSH_IMAGE }}
60+
tags: ${{ steps.meta.outputs.tags }}
61+
labels: ${{ steps.meta.outputs.labels }}
62+
cache-from: type=gha
63+
cache-to: type=gha,mode=max

0 commit comments

Comments
 (0)