From a412003f09a4b39a2705a774de367f3854bcb27b Mon Sep 17 00:00:00 2001 From: Jordan Webb Date: Thu, 13 May 2021 23:18:24 -0500 Subject: [PATCH] Swap publish for cibuild --- .github/workflows/cibuild.yml | 70 +++++++++++++++++++++++++++++++++++ .github/workflows/publish.yml | 58 ----------------------------- 2 files changed, 70 insertions(+), 58 deletions(-) create mode 100644 .github/workflows/cibuild.yml delete mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/cibuild.yml b/.github/workflows/cibuild.yml new file mode 100644 index 0000000..cd9ab28 --- /dev/null +++ b/.github/workflows/cibuild.yml @@ -0,0 +1,70 @@ +on: + pull_request: + branches: + - main + + push: + branches: + - main + + schedule: + - cron: '0 0 1/1 * *' + +name: Build + +env: + CONTAINER_NAME: jordemort/pleroma:${{ github.event.inputs.container_tag || 'latest' }} + CACHE_NAME: jordemort/pleroma:cache-unzip + PLATFORMS: linux/amd64,linux/arm64,linux/arm/v7 + DOCKER_CLI_EXPERIMENTAL: enabled + +jobs: + cibuild: + name: Build image + runs-on: ubuntu-20.04 + + steps: + - name: Set up QEMU + uses: docker/setup-qemu-action@v1.1.0 + + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v1.3.0 + + - name: Login to container registry + uses: docker/login-action@v1.9.0 + with: + username: ${{ secrets.REGISTRY_USERNAME }} + password: ${{ secrets.REGISTRY_TOKEN }} + + - uses: actions/checkout@v2.3.4 + with: + submodules: recursive + + - name: Pull cached containers + run: | + docker pull --platform "$PLATFORMS" --quiet "$CONTAINER_NAME" || true + docker pull --platform "$PLATFORMS" --quiet "$CACHE_NAME" || true + + - name: Build and push container + run: | + buildx_argv=( + --pull + --build-arg BUILDKIT_INLINE_CACHE=1 + --platform "$PLATFORMS" + --cache-from "$CONTAINER_NAME" + --tag "$CONTAINER_NAME" + ) + + if [ "${GITHUB_EVENT_NAME:-}" = "push" ] || [ "${GITHUB_EVENT_NAME:-}" = "schedule" ] ; then + buildx_argv+=(--push) + fi + + set -x + docker buildx build "${buildx_argv[@]}" --target unzip . + docker buildx build "${buildx_argv[@]}" . + + - uses: sarisia/actions-status-discord@v1 + if: always() + with: + webhook: ${{ secrets.DISCORD_WEBHOOK }} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml deleted file mode 100644 index 52650c5..0000000 --- a/.github/workflows/publish.yml +++ /dev/null @@ -1,58 +0,0 @@ -on: - workflow_dispatch: - inputs: - container_tag: - description: Tag for container - default: "latest" - required: true - - push: - branches: - - main - - schedule: - - cron: '0 0 1/1 * *' - -name: Publish container - -env: - CONTAINER_NAME: jordemort/pleroma:${{ github.event.inputs.container_tag || 'latest' }} - CACHE_NAME: jordemort/pleroma:cache-unzip - PLATFORMS: linux/amd64,linux/arm64,linux/arm/v7 - DOCKER_CLI_EXPERIMENTAL: enabled - -jobs: - publish: - name: Build and publish image - runs-on: ubuntu-20.04 - - steps: - - name: Set up QEMU - uses: docker/setup-qemu-action@v1 - - - name: Set up Docker Buildx - id: buildx - uses: docker/setup-buildx-action@v1 - - - name: Login to container registry - uses: docker/login-action@v1 - with: - username: ${{ secrets.REGISTRY_USERNAME }} - password: ${{ secrets.REGISTRY_TOKEN }} - - - uses: actions/checkout@v2 - - - name: Build and push container - run: | - docker buildx build --push --pull \ - --platform "$PLATFORMS" \ - --cache-from "$CACHE_NAME" \ - --tag "$CACHE_NAME" --target unzip . - - - name: Build and push container - run: | - docker buildx build --push --pull \ - --platform "$PLATFORMS" \ - --cache-from "$CACHE_NAME" \ - --cache-from "$CONTAINER_NAME" \ - --tag "$CONTAINER_NAME" .