From 2f07b107edb7d4a91e23b7e36baeb724f3a7a587 Mon Sep 17 00:00:00 2001 From: Bob Adriyanti Date: Sun, 4 Feb 2024 15:09:35 +0300 Subject: [PATCH] Commit to docker only on tags, remove automated tags, created manually only --- .github/workflows/pull_request.yml | 1 + .github/workflows/push.yml | 23 +++++++++-------------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 87d71a71..e46a5372 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -1,4 +1,5 @@ name: CI/CD Pipeline for Pull Requests to Master + 'on': pull_request: branches: diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 1c464f8a..5ac9094f 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -1,8 +1,10 @@ -name: CI/CD Pipeline for Push to Master +name: CI/CD Pipeline for Docker Tag Push + 'on': push: - branches: - - master + tags: + - 'v*' + jobs: test: runs-on: ubuntu-latest @@ -22,17 +24,13 @@ jobs: - name: Run tests run: npm test timeout-minutes: 1 + docker: needs: test runs-on: ubuntu-latest steps: - - name: Fetch latest wwebjs tag - id: fetch-wwebjs-tag - run: | - repo="pedroslopez/whatsapp-web.js" - latest_tag=$(curl -s "https://api.github.com/repos/$repo/tags" | jq -r .[0].name) - docker_friendly_tag=$(echo "$latest_tag" | tr '.-' '__') - echo "tag=$docker_friendly_tag" >> "$GITHUB_OUTPUT" + - name: Checkout repository + uses: actions/checkout@v3 - name: Set up QEMU uses: docker/setup-qemu-action@v2 - name: Set up Docker Buildx @@ -42,14 +40,11 @@ jobs: with: username: '${{ secrets.DOCKER_HUB_USERNAME }}' password: '${{ secrets.DOCKER_HUB_TOKEN }}' - - name: Actual tag from fetch-tag job - run: | - echo "Tag from fetch-tag job: ${{ steps.fetch-wwebjs-tag.outputs.tag }}" - name: Build and push with dynamic tag uses: docker/build-push-action@v4 with: platforms: linux/amd64,linux/arm64,linux/arm/v7 push: true tags: | - chrishubert/whatsapp-web-api:${{ steps.fetch-wwebjs-tag.outputs.tag }} + chrishubert/whatsapp-web-api:${{ github.ref_name }} chrishubert/whatsapp-web-api:latest \ No newline at end of file