From 4bdad6406053428e9f6de9418b9fb063454745fc Mon Sep 17 00:00:00 2001 From: bgme Date: Wed, 7 Jun 2023 17:34:22 +0800 Subject: [PATCH 1/2] add build-publish-docker.yml --- .github/workflows/build-publish-docker.yml | 58 ++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 .github/workflows/build-publish-docker.yml diff --git a/.github/workflows/build-publish-docker.yml b/.github/workflows/build-publish-docker.yml new file mode 100644 index 0000000..303dd9b --- /dev/null +++ b/.github/workflows/build-publish-docker.yml @@ -0,0 +1,58 @@ +name: Build and Publish Docker + +on: + push: + branches: ["master"] + paths-ignore: ["README.md"] + pull_request: + branches: ["master"] + paths-ignore: ["README.md"] + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +permissions: + contents: read + packages: write + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Set up QEMU + id: qemu + uses: docker/setup-qemu-action@v2 + with: + platforms: arm64 + + - name: Setup Docker buildx + id: buildx + uses: docker/setup-buildx-action@v2 + + - name: Log in to GHCR + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@v4 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Build and push Docker image + id: build-and-push + uses: docker/build-push-action@v4 + with: + context: . + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max From 71fab89046a216baf382f41a3248d997635d6fe4 Mon Sep 17 00:00:00 2001 From: bgme Date: Wed, 7 Jun 2023 17:50:13 +0800 Subject: [PATCH 2/2] update build-publish-docker.yml --- .github/workflows/build-docker.yml | 58 ---------------------- .github/workflows/build-publish-docker.yml | 8 +-- 2 files changed, 5 insertions(+), 61 deletions(-) delete mode 100644 .github/workflows/build-docker.yml diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml deleted file mode 100644 index 754f080..0000000 --- a/.github/workflows/build-docker.yml +++ /dev/null @@ -1,58 +0,0 @@ -name: Docker - -on: - push: - paths-ignore: - - "README.md" - branches: - - master - -jobs: - build-docker-amd64: - runs-on: buildjet-2vcpu-ubuntu-2204 - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - name: Set up Docker Buildx - id: buildx - uses: docker/setup-buildx-action@v2 - with: - version: latest - - name: Login to DockerHub - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - - name: Build and push AMD64 Docker image - uses: docker/build-push-action@v3 - with: - context: . - file: ./Dockerfile - platforms: linux/amd64 - push: true - tags: zedeus/nitter:latest,zedeus/nitter:${{ github.sha }} - build-docker-arm64: - runs-on: buildjet-2vcpu-ubuntu-2204-arm - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - name: Set up Docker Buildx - id: buildx - uses: docker/setup-buildx-action@v2 - with: - version: latest - - name: Login to DockerHub - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - - name: Build and push ARM64 Docker image - uses: docker/build-push-action@v3 - with: - context: . - file: ./Dockerfile.arm64 - platforms: linux/arm64 - push: true - tags: zedeus/nitter:latest-arm64,zedeus/nitter:${{ github.sha }}-arm64 diff --git a/.github/workflows/build-publish-docker.yml b/.github/workflows/build-publish-docker.yml index 303dd9b..d32a220 100644 --- a/.github/workflows/build-publish-docker.yml +++ b/.github/workflows/build-publish-docker.yml @@ -9,7 +9,6 @@ on: paths-ignore: ["README.md"] env: - REGISTRY: ghcr.io IMAGE_NAME: ${{ github.repository }} permissions: @@ -44,9 +43,11 @@ jobs: id: meta uses: docker/metadata-action@v4 with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + images: | + ghcr.io/${{ env.IMAGE_NAME }} + - - name: Build and push Docker image + - name: Build and push all platforms Docker image id: build-and-push uses: docker/build-push-action@v4 with: @@ -54,5 +55,6 @@ jobs: push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} + platforms: linux/amd64,linux/arm64 cache-from: type=gha cache-to: type=gha,mode=max