From a112c1c067151ae719af5a423491a1a1a3014a0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Wed, 24 Jul 2024 08:36:27 +0200 Subject: [PATCH] ci: Build docker image MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- .github/workflows/docker.yml | 87 ++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 .github/workflows/docker.yml diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000..3e297a4 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,87 @@ +name: Docker image + +on: + push: + branches: + - ci/docker + - main + - master + - stable* + tags: + - "v*" + +env: + # DOCKER_REPO: nextcloud/whiteboard + GHCR_REPO: ghcr.io/nextcloud/whiteboard + +jobs: + build: + runs-on: ubuntu-latest + timeout-minutes: 30 + + strategy: + matrix: + platform: + - linux/amd64 + - linux/arm64 + - linux/arm/v5 + - linux/arm/v7 + + steps: + - name: Set vars + id: vars + run: | + echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT + echo "platform=$(echo -n ${{ matrix.platform }} | sed 's/\//-/g')" >> $GITHUB_OUTPUT + + - uses: actions/checkout@v3 + - uses: docker/setup-qemu-action@v3 + - uses: docker/setup-buildx-action@v3 + + - name: Login to Github Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build docker images + uses: docker/build-push-action@v3 + with: + context: . + push: true + platforms: ${{ matrix.platform }} + tags: | + ${{ env.GHCR_REPO}}:${{ steps.vars.outputs.version }}-${{ steps.vars.outputs.platform }} + + release: + runs-on: ubuntu-latest + timeout-minutes: 10 + needs: build + + steps: + - name: Set vars + id: vars + run: | + echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT + echo "version=daily" >> $GITHUB_OUTPUT + + - name: Login to Github Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Create GHCR manifest + run: | + docker manifest create $GHCR_REPO:${{ steps.vars.outputs.version }} \ + $GHCR_REPO:${{ steps.vars.outputs.version }}-linux-amd64 \ + $GHCR_REPO:${{ steps.vars.outputs.version }}-linux-arm64 \ + $GHCR_REPO:${{ steps.vars.outputs.version }}-linux-arm-v5 \ + $GHCR_REPO:${{ steps.vars.outputs.version }}-linux-arm-v7 + + - name: Push manifests + run: | + docker manifest push $DOCKER_REPO:${{ steps.vars.outputs.version }} + docker manifest push $GHCR_REPO:${{ steps.vars.outputs.version }} \ No newline at end of file