From 387accd8435078fd9e199578015818b134034ccc Mon Sep 17 00:00:00 2001 From: Oliver Ni Date: Sun, 17 Jul 2022 16:50:38 -0700 Subject: [PATCH] Update CI --- .github/workflows/publish.yml | 60 ++++++++++++++--------------------- 1 file changed, 23 insertions(+), 37 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 088b4b6..608eed2 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,50 +1,36 @@ -name: Build Docker Images -on: [push] +name: Build Image -jobs: - build-docker-image: - strategy: - matrix: - target-cpu: ["znver3", "znver2", "skylake", "haswell", "sandybridge", "x86-64"] +permissions: + packages: write - name: Build for ${{ matrix.target-cpu }} - env: - DOCKER_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }} - DOCKER_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} - DOCKER_TARGET_ACCOUNT: ${{ secrets.DOCKERHUB_TARGET }} +on: + push: + pull_request: +jobs: + build: runs-on: ubuntu-latest steps: - - name: Checkout sources - uses: actions/checkout@v3 + - uses: docker/setup-buildx-action@v2 - - name: Login to DockerHub - uses: docker/login-action@v2 - if: env.DOCKER_USERNAME + - id: metadata + uses: docker/metadata-action@v4 with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_PASSWORD }} + images: ghcr.io/poketwo/gateway-proxy - - name: Login to ghcr - uses: docker/login-action@v2 + - uses: docker/login-action@v2 with: registry: ghcr.io username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Convert GITHUB_REPOSITORY into lowercase - run: | - echo "REPO=${GITHUB_REPOSITORY,,}" >>${GITHUB_ENV} + password: ${{ secrets.GHCR_PAT }} - - name: Build Docker Image - run: | - docker build -t gateway-proxy:${{ matrix.target-cpu }} --build-arg TARGET_CPU=${{ matrix.target-cpu }} . - - - name: Create manifest and push it - if: env.DOCKER_USERNAME && github.ref == 'refs/heads/main' - run: | - docker tag gateway-proxy:${{ matrix.target-cpu }} ${{ secrets.DOCKERHUB_TARGET }}/gateway-proxy:${{ matrix.target-cpu }} - docker push ${{ secrets.DOCKERHUB_TARGET }}/gateway-proxy:${{ matrix.target-cpu }} + - uses: docker/build-push-action@v4 + with: + tags: ${{ steps.metadata.outputs.tags }} + labels: ${{ steps.metadata.outputs.tags }} + cache-from: type=gha + cache-to: type=gha,mode=max + push: true + secrets: | + GIT_AUTH_TOKEN=${{ secrets.GHCR_PAT }} - docker tag gateway-proxy:${{ matrix.target-cpu }} ghcr.io/${REPO}:${{ matrix.target-cpu }} - docker push ghcr.io/${REPO}:${{ matrix.target-cpu }}