.github/workflows/build.yml #1331
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
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
schedule: | |
- cron: '0 0 * * *' | |
concurrency: | |
group: build-${{ format('{0}-{1}', github.head_ref || github.run_number, github.job) }} | |
cancel-in-progress: true | |
env: | |
BUILDKIT_PROGRESS: plain | |
jobs: | |
base: | |
runs-on: ubuntu-20.04${{ ((github.event_name != 'schedule') && '-8core') || '' }} | |
timeout-minutes: 90 | |
steps: | |
- name: enable experimental docker features | |
run: | | |
sudo bash -c 'echo "{ \"cgroup-parent\": \"/actions_job\",\"experimental\":true}" > /etc/docker/daemon.json' | |
sudo service docker restart | |
docker version -f '{{.Server.Experimental}}' | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 1 | |
- name: build slim image | |
run: | | |
cd image && ruby auto_build.rb base_slim | |
- name: tag slim images | |
id: tag-images | |
run: | | |
TAG=`date +%Y%m%d-%H%M` | |
echo "tag=$(echo $TAG)" >> $GITHUB_OUTPUT | |
docker tag discourse/base:build_slim discourse/base:2.0.$TAG-slim | |
docker tag discourse/base:build_slim discourse/base:slim | |
- name: build release image | |
run: | | |
cd image && ruby auto_build.rb base | |
- name: tag release images | |
run: | | |
TAG=${{ steps.tag-images.outputs.tag }} | |
docker tag discourse/base:build discourse/base:2.0.$TAG | |
docker tag discourse/base:build discourse/base:release | |
- name: build test_build image | |
run: | | |
cd image && ruby auto_build.rb discourse_test_build | |
- name: run specs | |
run: | | |
docker run --rm -e RUBY_ONLY=1 -e USE_TURBO=1 -e SKIP_PLUGINS=1 -e SKIP_LINT=1 discourse/discourse_test:build | |
- name: Print summary | |
run: | | |
docker images discourse/base | |
- name: push to dockerhub | |
if: success() && (github.ref == 'refs/heads/main') | |
env: | |
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }} | |
run: | | |
TAG=${{ steps.tag-images.outputs.tag }} | |
docker login --username discoursebuild --password $DOCKERHUB_PASSWORD | |
docker push discourse/base:2.0.$TAG-slim | |
docker push discourse/base:slim | |
docker push discourse/base:2.0.$TAG | |
docker push discourse/base:release | |
test: | |
runs-on: ubuntu-20.04${{ ((github.event_name != 'schedule') && '-8core') || '' }} | |
timeout-minutes: 30 | |
needs: base | |
defaults: | |
run: | |
working-directory: image/discourse_test | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 1 | |
- name: build discourse_test:slim | |
run: | | |
docker buildx build . --load \ | |
--build-arg from_tag=slim \ | |
--target base \ | |
--tag discourse/discourse_test:slim | |
- name: build discourse_test:slim-browsers | |
run: | | |
docker buildx build . --load \ | |
--build-arg from_tag=slim \ | |
--target with_browsers \ | |
--tag discourse/discourse_test:slim-browsers | |
- name: build discourse_test:release | |
run: | | |
docker buildx build . --load \ | |
--build-arg from_tag=release \ | |
--target release \ | |
--tag discourse/discourse_test:release | |
- name: Print summary | |
run: | | |
docker images discourse/discourse_test | |
- name: push to dockerhub | |
if: success() && (github.ref == 'refs/heads/main') | |
env: | |
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }} | |
run: | | |
docker login --username discoursebuild --password $DOCKERHUB_PASSWORD | |
docker push discourse/discourse_test:slim | |
docker push discourse/discourse_test:slim-browsers | |
docker push discourse/discourse_test:release | |
dev: | |
runs-on: ubuntu-20.04${{ ((github.event_name != 'schedule') && '-8core') || '' }} | |
timeout-minutes: 30 | |
needs: base | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 1 | |
- name: build discourse_dev image | |
run: | | |
cd image && ruby auto_build.rb discourse_dev | |
- name: push to dockerhub | |
if: success() && (github.ref == 'refs/heads/main') | |
env: | |
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }} | |
run: | | |
docker tag discourse/discourse_dev:build discourse/discourse_dev:release | |
docker login --username discoursebuild --password $DOCKERHUB_PASSWORD | |
docker push discourse/discourse_dev:release | |
aarch64: | |
runs-on: ubuntu-latest | |
needs: base | |
services: | |
registry: | |
image: registry | |
ports: | |
- 5000:5000 | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 1 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx | |
id: buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: build slim image | |
working-directory: image/base | |
run: | | |
docker buildx build . --load \ | |
-f slim.Dockerfile \ | |
--platform linux/arm64 \ | |
--tag discourse/base:aarch64-slim | |
docker tag discourse/base:aarch64-slim localhost:5000/discourse/base:aarch64-slim | |
docker push localhost:5000/discourse/base:aarch64-slim | |
- name: tag slim image as release | |
working-directory: image/base | |
run: | | |
docker tag discourse/base:aarch64-slim discourse/base:aarch64 | |
- name: Print summary | |
run: docker images discourse/base | |
- name: push to dockerhub | |
if: success() && (github.ref == 'refs/heads/main') | |
env: | |
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }} | |
run: | | |
docker login --username discoursebuild --password $DOCKERHUB_PASSWORD | |
docker push discourse/base:aarch64 |