From db0253cbde184fb4c4922ee10324107c3ce2cc4b 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 | 74 ++++++++++++++---------------------- 1 file changed, 28 insertions(+), 46 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index a7d9233f8554..1b69e23d4539 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -1,63 +1,45 @@ -name: Build docker image +name: Build Docker Image on: release: types: [published] 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=sha - 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 }} + 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@v6 - with: - context: . - platforms: | - linux/amd64 - linux/arm64 - linux/loong64 - linux/riscv64 - provenance: false - file: .github/docker/Dockerfile - push: true - tags: ${{ steps.meta.outputs.tags }} - - name: Build and push Loyalsoldier flavor + + - name: Build uses: docker/build-push-action@v6 + env: + DOCKER_BUILD_SUMMARY: false with: - context: . - platforms: | - linux/amd64 - linux/arm64 - linux/loong64 - linux/riscv64 - provenance: false file: .github/docker/Dockerfile - build-args: flavor=loyalsoldier - push: true - tags: | - ${{ steps.loyalsoldier.outputs.tags }} + push: ${{ contains(github.ref, 'refs/tags/') }} # push if tag was set + tags: ${{ steps.metadata.outputs.tags }}