Merge pull request #107 from avoylenko/master #69
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI/CD Pipeline for Push to Master | |
'on': | |
push: | |
branches: | |
- master | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: | |
- 14.x | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: 'Use Node.js ${{ matrix.node-version }}' | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '${{ matrix.node-version }}' | |
- name: Install dependencies | |
run: npm ci | |
- 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: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v2 | |
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:latest |