Skip to content

Commit

Permalink
Merge pull request #154 from chrishubert/improve-github-actions
Browse files Browse the repository at this point in the history
Commit to docker only on tags
  • Loading branch information
chrishubert authored Feb 4, 2024
2 parents 8d3ea5c + 2f07b10 commit 6057f55
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
1 change: 1 addition & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: CI/CD Pipeline for Pull Requests to Master

'on':
pull_request:
branches:
Expand Down
23 changes: 9 additions & 14 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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

0 comments on commit 6057f55

Please sign in to comment.