From 39d21bfa20c2a085e175a49d3b28ecb09547882b Mon Sep 17 00:00:00 2001 From: tiaga <10153548+tiaga@users.noreply.github.com> Date: Fri, 18 Oct 2024 23:32:43 +0700 Subject: [PATCH] Improve CI/CD schema --- .github/workflows/docker.yml | 60 +++++++++++++++++------------------- 1 file changed, 29 insertions(+), 31 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index f88c6e64ba6e..5e5559bb3cfd 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -1,45 +1,43 @@ -name: Build docker image +name: Build Docker Image on: push: - branches: - - main + tags: + - '[0-9]+.[0-9]+.[0-9]+' + pull_request: + +env: + APP: amnezia-xray-core jobs: build-image: runs-on: ubuntu-latest - permissions: - packages: write + name: build-image steps: - - uses: actions/checkout@v4 - - name: Docker metadata - id: meta - uses: docker/metadata-action@v5 - with: - images: ghcr.io/${{ github.repository_owner }}/amnezia-xray-core - flavor: latest=true - tags: | - type=ref,event=branch - type=ref,event=pr - type=semver,pattern={{version}} - - name: Login to GitHub Container Registry + - name: Checkout + uses: actions/checkout@v4 + + - name: Login to Docker Hub uses: docker/login-action@v3 with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} - - # Add support for more platforms with QEMU (optional) - # https://github.com/docker/setup-qemu-action - name: Set up QEMU - uses: docker/setup-qemu-action@v3 + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Setup metadata + uses: docker/metadata-action@v5 + id: metadata + with: + images: amneziavpn/${{ env.APP }} + tags: type=semver,pattern={{version}} + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - - name: Build and push - uses: docker/build-push-action@v5 + + - name: Build + uses: docker/build-push-action@v6 + env: + DOCKER_BUILD_SUMMARY: false with: - context: . - platforms: linux/amd64,linux/arm64 file: .github/docker/Dockerfile - push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} + push: ${{ contains(github.ref, 'refs/tags/') }} # push if tag was set + tags: ${{ steps.metadata.outputs.tags }}