From b93344b0463cbb8d8ad9186f8ff991d676637fb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?s=E1=B4=A7=E1=B4=8D=E1=B4=9C=E1=B4=87=CA=9F=20=E1=B4=8D?= Date: Thu, 15 Feb 2024 01:05:32 +0000 Subject: [PATCH] Update main.yml --- .github/workflows/main.yml | 67 ++++++++++++++++++++------------------ 1 file changed, 35 insertions(+), 32 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 831041d..e80dbba 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,41 +1,44 @@ -name: Build and Publish Docker Image +name: ci on: push: branches: - - main + - "**" tags: - - 'v*' # Trigger on tags that start with 'v' + - "v*.*.*" jobs: - build-and-publish: + docker: runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v4.1.1 - - - name: Setup Docker Buildx - uses: docker/setup-buildx-action@v3.0.0 - - - name: Login to Docker Hub - uses: docker/login-action@v3.0.0 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Tag and publish image (main branch) - if: github.ref == 'refs/heads/main' - uses: docker/build-push-action@v5.1.0 - with: - push: true - tags: ${{ secrets.DOCKERHUB_USERNAME }}/brudi-rclone:latest - - - name: Tag and publish image (git tags) - if: startsWith(github.event.ref, 'refs/tags/') - uses: docker/build-push-action@v5.1.0 - with: - push: true - tag: ${{ secrets.DOCKERHUB_USERNAME }}/brudi-rclone:${{ github.ref_name }} - - + - name: Checkout + uses: actions/checkout@v4 + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + # list of Docker images to use as base name for tags + images: | + ${{ secrets.DOCKERHUB_USERNAME }}/brudi-rclone + # generate Docker tags based on the following events/attributes + tags: | + type=ref,event=branch + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + type=sha + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Login to Docker Hub + if: github.event_name != 'pull_request' + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Build and push + uses: docker/build-push-action@v5 + with: + context: . + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }}