diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 088b4b6..f87dd7c 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,50 +1,36 @@ -name: Build Docker Images -on: [push] +name: Build and Push -jobs: - build-docker-image: - strategy: - matrix: - target-cpu: ["znver3", "znver2", "skylake", "haswell", "sandybridge", "x86-64"] +on: + push: + branches: + - main - name: Build for ${{ matrix.target-cpu }} - env: - DOCKER_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }} - DOCKER_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} - DOCKER_TARGET_ACCOUNT: ${{ secrets.DOCKERHUB_TARGET }} +permissions: + contents: read + packages: write +jobs: + build: runs-on: ubuntu-latest steps: - - name: Checkout sources - uses: actions/checkout@v3 + - uses: docker/setup-buildx-action@v3 - - name: Login to DockerHub - uses: docker/login-action@v2 - if: env.DOCKER_USERNAME + - id: metadata + uses: docker/metadata-action@v5 with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_PASSWORD }} + images: ghcr.io/${{ github.repository }} + flavor: latest=true - - name: Login to ghcr - uses: docker/login-action@v2 + - uses: docker/login-action@v3 with: registry: ghcr.io - username: ${{ github.actor }} + username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Convert GITHUB_REPOSITORY into lowercase - run: | - echo "REPO=${GITHUB_REPOSITORY,,}" >>${GITHUB_ENV} - - - 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 }} - - docker tag gateway-proxy:${{ matrix.target-cpu }} ghcr.io/${REPO}:${{ matrix.target-cpu }} - docker push ghcr.io/${REPO}:${{ matrix.target-cpu }} + - uses: docker/build-push-action@v6 + with: + tags: ${{ steps.metadata.outputs.tags }} + labels: ${{ steps.metadata.outputs.tags }} + cache-from: type=gha + cache-to: type=gha,mode=max + push: true