Skip to content

Commit 1b2dd2d

Browse files
FEATURE: build and push web only images to discourse/discourse
push image with 4 tags: latest stable x.y.z (stable by current version) x.y.z.betax-dev (latest by current version)
1 parent 8bd0b66 commit 1b2dd2d

File tree

1 file changed

+121
-0
lines changed

1 file changed

+121
-0
lines changed
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
on:
2+
# push:
3+
# branches:
4+
# - main
5+
schedule:
6+
- cron: "0 0 * * *"
7+
8+
env:
9+
BUILDKIT_PROGRESS: plain
10+
DOCKER_REPO: discourse/discourse
11+
12+
jobs:
13+
version:
14+
runs-on: ubuntu-latest
15+
outputs:
16+
tests-passed: ${{ steps.latest.outputs.version }}
17+
stable: ${{ steps.stable.outputs.version }}
18+
steps:
19+
- uses: ruby/setup-ruby@v1
20+
with:
21+
ruby-version: '3.3'
22+
- name: checkout tests passed
23+
uses: actions/checkout@v4
24+
with:
25+
repository: discourse/discourse
26+
ref: tests-passed
27+
fetch-depth: 1
28+
path: 'tests-passed'
29+
- name: checkout stable
30+
uses: actions/checkout@v4
31+
with:
32+
repository: discourse/discourse
33+
ref: stable
34+
fetch-depth: 1
35+
path: 'stable'
36+
- id: latest
37+
working-directory: tests-passed
38+
run: |
39+
version=$(ruby -r ./lib/version.rb -e "puts ::Discourse::VERSION::STRING")
40+
echo "version=$version"
41+
echo "version=$version" >> $GITHUB_OUTPUT
42+
- id: stable
43+
working-directory: stable
44+
run: |
45+
version=$(ruby -r ./lib/version.rb -e "puts ::Discourse::VERSION::STRING")
46+
echo "version=$version"
47+
echo "version=$version" >> $GITHUB_OUTPUT
48+
49+
push:
50+
strategy:
51+
matrix:
52+
version: [tests-passed,stable]
53+
os: [ubuntu-latest, ubuntu-24.04-arm]
54+
runs-on: ${{ matrix.os }}
55+
needs: version
56+
env:
57+
ARCH: ${{ matrix.os == 'ubuntu-24.04-arm' && 'arm64' || 'amd64' }}
58+
FLOATING_TAG: ${{ matrix.version == 'tests-passed' && 'latest' || matrix.version }}-${{ matrix.os == 'ubuntu-24.04-arm' && 'arm64' || 'amd64' }}
59+
TAG: ${{ matrix.version == 'stable' && needs.version.outputs.stable || needs.version.outputs.tests-passed }}-${{ matrix.os == 'ubuntu-24.04-arm' && 'arm64' || 'amd64' }}
60+
steps:
61+
- uses: actions/checkout@v4
62+
with:
63+
fetch-depth: 1
64+
- name: download-launcher
65+
run: |
66+
BINDIR="bin"
67+
package="${BINDIR}/launcher.tar.gz"
68+
curl -s -o ${package} -L https://get.discourse.org/launcher/latest/launcher-linux-${{ env.ARCH }}.tar.gz
69+
tar -zxf ${package} -C ${BINDIR}
70+
rm ${package}
71+
- uses: docker/setup-buildx-action@v3
72+
- name: build
73+
run: |
74+
docker login --username ${{ vars.DOCKERHUB_USERNAME }} --password ${{ secrets.DOCKER_PASSWORD }}
75+
# TODO: can we find a way to override or provide pups params at build time?
76+
# Then we can do something like:
77+
# bin/launcher build --params="version=stable" --conf-dir=./samples web_only
78+
cp ./samples/web_only.yml ./containers/web_only.yml
79+
sed -Ei 's/^ *+#?version:.*/ version: ${{ matrix.version }}/' ./containers/web_only.yml
80+
sed -Ei '/^ *+- "templates\/web.template.yml"/a\ - "templates/offline-page.template.yml"' ./containers/web_only.yml
81+
# TODO: enable lets encrypt build
82+
# Once https://github.com/discourse/discourse_docker/pull/977 is merged
83+
# uncomment the next two lines to apply the let's encrypt template to the base image
84+
#sed -Ei 's/^ *+#- "templates\/web.ssl.template.yml"/ - "templates\/web.ssl.template.yml"/' ./containers/web_only.yml
85+
#sed -Ei 's/^ *+#- "templates\/web.letsencrypt.ssl.template.yml"/ - "templates\/web.letsencrypt.ssl.template.yml"/' ./containers/web_only.yml
86+
bin/launcher build web_only \
87+
--tag ${{ env.DOCKER_REPO }}:${{ env.FLOATING_TAG }} \
88+
--tag ${{ env.DOCKER_REPO }}:${{ env.TAG }} \
89+
--push
90+
91+
manifest:
92+
runs-on: ubuntu-latest
93+
needs: [version, push]
94+
steps:
95+
- uses: docker/setup-buildx-action@v3
96+
- name: update manifest
97+
run: |
98+
docker login --username ${{ vars.DOCKERHUB_USERNAME }} --password ${{ secrets.DOCKER_PASSWORD }}
99+
docker manifest create \
100+
${{ env.DOCKER_REPO }}:latest \
101+
--amend ${{ env.DOCKER_REPO }}:latest-amd64 \
102+
--amend ${{ env.DOCKER_REPO }}:latest-arm64
103+
docker manifest push ${{ env.DOCKER_REPO }}:latest
104+
105+
docker manifest create \
106+
${{ env.DOCKER_REPO }}:stable \
107+
--amend ${{ env.DOCKER_REPO }}:stable-amd64 \
108+
--amend ${{ env.DOCKER_REPO }}:stable-arm64
109+
docker manifest push ${{ env.DOCKER_REPO }}:stable
110+
111+
docker manifest create \
112+
${{ env.DOCKER_REPO }}:${{ needs.version.outputs.tests-passed }} \
113+
--amend ${{ env.DOCKER_REPO }}:${{ needs.version.outputs.tests-passed }}-amd64 \
114+
--amend ${{ env.DOCKER_REPO }}:${{ needs.version.outputs.tests-passed }}-arm64
115+
docker manifest push ${{ env.DOCKER_REPO }}:${{ needs.version.outputs.tests-passed }}
116+
117+
docker manifest create \
118+
${{ env.DOCKER_REPO }}:${{ needs.version.outputs.stable }} \
119+
--amend ${{ env.DOCKER_REPO }}:${{ needs.version.outputs.stable }}-amd64 \
120+
--amend ${{ env.DOCKER_REPO }}:${{ needs.version.outputs.stable }}-arm64
121+
docker manifest push ${{ env.DOCKER_REPO }}:${{ needs.version.outputs.stable }}

0 commit comments

Comments
 (0)