chores #11
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: Pull Request | |
on: | |
# Note that GITHUB_SHA for this event is the last merge commit of the pull | |
# request merge branch. If you want to get the commit ID for the last commit | |
# to the head branch of the pull request, | |
# use github.event.pull_request.head.sha instead. | |
# Docs: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request | |
pull_request: | |
types: [opened, synchronize, reopened] | |
branches: | |
- 'v*' | |
jobs: | |
build: | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Clone repo | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set .nvmrc content to stage output | |
id: nvmrc | |
run: | | |
echo "node_version=$(cat .nvmrc | sed 's/v//g')" >> $GITHUB_OUTPUT | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ steps.nvmrc.outputs.node_version }} | |
- name: Install dependencies | |
run: npm ci | |
- name: Check git tag for version | |
run: | | |
PACKAGE_VERSION=$(node -p "require('./package.json').version") | |
echo "Current version in package.json: $PACKAGE_VERSION" | |
if git rev-parse "${PACKAGE_VERSION}" >/dev/null 2>&1; then | |
echo "Error: git tag ${PACKAGE_VERSION} already exists." | |
exit 1 | |
else | |
echo "Good: no matching git tag exists for version ${PACKAGE_VERSION}" | |
fi | |
- name: Run tests | |
run: npm run test | |
env: | |
GITHUB_TOKEN: ${{ secrets.GH_TKN }} | |
# docs: https://github.com/marketplace/actions/build-and-push-docker-images | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
# docs: https://docs.docker.com/build/ci/github-actions/test-before-push/ | |
- name: Build Docker image | |
uses: docker/build-push-action@v5 | |
with: | |
push: false | |
context: . | |
load: true | |
tags: github-commit-sign:latest | |
- name: Run Docker tests | |
env: | |
GITHUB_TOKEN: ${{ secrets.GH_TKN }} | |
run: npm run docker:test |