|
| 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.DOCKERHUB_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 | + # TODO: Uncomment when PR 966 is merged |
| 80 | + # allowing us to build from web-only images |
| 81 | + # https://github.com/discourse/discourse_docker/pull/966 |
| 82 | + #echo $(grep base_image: ./templates/web.template.yml)-web-only >> ./containers/web_only.yml |
| 83 | + sed -Ei 's/^ *+#?version:.*/ version: ${{ matrix.version }}/' ./containers/web_only.yml |
| 84 | + sed -Ei '/^ *+- "templates\/web.template.yml"/a\ - "templates/offline-page.template.yml"' ./containers/web_only.yml |
| 85 | + sed -Ei 's/^ *+#- "templates\/web.ssl.template.yml"/ - "templates\/web.ssl.template.yml"/' ./containers/web_only.yml |
| 86 | + sed -Ei 's/^ *+#- "templates\/web.letsencrypt.ssl.template.yml"/ - "templates\/web.letsencrypt.ssl.template.yml"/' ./containers/web_only.yml |
| 87 | + bin/launcher build web_only \ |
| 88 | + --tag ${{ env.DOCKER_REPO }}:${{ env.FLOATING_TAG }} \ |
| 89 | + --tag ${{ env.DOCKER_REPO }}:${{ env.TAG }} \ |
| 90 | + --push |
| 91 | +
|
| 92 | + manifest: |
| 93 | + runs-on: ubuntu-latest |
| 94 | + needs: [version, push] |
| 95 | + steps: |
| 96 | + - uses: docker/setup-buildx-action@v3 |
| 97 | + - name: update manifest |
| 98 | + run: | |
| 99 | + docker login --username ${{ vars.DOCKERHUB_USERNAME }} --password ${{ secrets.DOCKERHUB_PASSWORD }} |
| 100 | + docker manifest create \ |
| 101 | + ${{ env.DOCKER_REPO }}:latest \ |
| 102 | + --amend ${{ env.DOCKER_REPO }}:latest-amd64 \ |
| 103 | + --amend ${{ env.DOCKER_REPO }}:latest-arm64 |
| 104 | + docker manifest push ${{ env.DOCKER_REPO }}:latest |
| 105 | +
|
| 106 | + docker manifest create \ |
| 107 | + ${{ env.DOCKER_REPO }}:stable \ |
| 108 | + --amend ${{ env.DOCKER_REPO }}:stable-amd64 \ |
| 109 | + --amend ${{ env.DOCKER_REPO }}:stable-arm64 |
| 110 | + docker manifest push ${{ env.DOCKER_REPO }}:stable |
| 111 | +
|
| 112 | + docker manifest create \ |
| 113 | + ${{ env.DOCKER_REPO }}:${{ needs.version.outputs.tests-passed }} \ |
| 114 | + --amend ${{ env.DOCKER_REPO }}:${{ needs.version.outputs.tests-passed }}-amd64 \ |
| 115 | + --amend ${{ env.DOCKER_REPO }}:${{ needs.version.outputs.tests-passed }}-arm64 |
| 116 | + docker manifest push ${{ env.DOCKER_REPO }}:${{ needs.version.outputs.tests-passed }} |
| 117 | +
|
| 118 | + docker manifest create \ |
| 119 | + ${{ env.DOCKER_REPO }}:${{ needs.version.outputs.stable }} \ |
| 120 | + --amend ${{ env.DOCKER_REPO }}:${{ needs.version.outputs.stable }}-amd64 \ |
| 121 | + --amend ${{ env.DOCKER_REPO }}:${{ needs.version.outputs.stable }}-arm64 |
| 122 | + docker manifest push ${{ env.DOCKER_REPO }}:${{ needs.version.outputs.stable }} |
0 commit comments