FIX: change request format #47
Workflow file for this run
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: Run tests | |
on: | |
pull_request: | |
branches: | |
- master | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '22' | |
- name: Install dependencies | |
# Install rollup manually because of bug with optional dependencies (https://github.com/npm/cli/issues/4828) | |
run: npm install && npm install -D @rollup/rollup-linux-x64-gnu && npx playwright install | |
- name: Run tests | |
run: npm test | |
env: | |
PUBLIC_API_BASE_URL: ${{ vars.PUBLIC_API_BASE_URL }} | |
PUBLIC_IMAGE_BASE_URL: ${{ vars.PUBLIC_IMAGE_BASE_URL }} | |
- name: Test docker build | |
run: docker build -t test . | |
version: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- uses: actions/create-github-app-token@v1 | |
id: app-token | |
with: | |
app-id: ${{ secrets.APP_CLIENT_ID }} | |
private-key: ${{ secrets.APP_PRIVATE_KEY }} | |
- name: Auth GitHub CLI | |
run: echo "GH_TOKEN=${{steps.app-token.outputs.token}}" >> $GITHUB_ENV | |
- name: Get version from package.json | |
run: | | |
VERSION=$(jq -r '.version' package.json) | |
echo "Version: $VERSION" | |
echo "VERSION=${VERSION}" >> $GITHUB_ENV | |
- name: Check Tag | |
run: | | |
TAG_EXISTS=$(gh release list --json tagName --jq '.[] | select(.tagName == "${{ env.VERSION }}") | length') | |
if [ "$TAG_EXISTS" -gt 0 ]; then | |
echo "Tag ${VERSION} already exists. Blocking the PR." | |
echo "BLOCK_PR=true" >> $GITHUB_ENV | |
else | |
echo "Tag ${VERSION} does not exist." | |
echo "BLOCK_PR=false" >> $GITHUB_ENV | |
fi | |
- name: Block PR | |
if: env.BLOCK_PR == 'true' | |
run: | | |
existing_reviews=$(gh pr view ${{ github.event.pull_request.number }} --json reviews --jq '.reviews[] | select(.body | contains("Version `${{ env.VERSION }}` already exists"))') | |
if [[ -n "$existing_reviews" ]]; then | |
echo "A similar review already exists. Skipping the review request." | |
else | |
gh pr review ${{ github.event.pull_request.number }} --request-changes --body "Version \`${{ env.VERSION }}\` already exists; this will overwrite the existing release. If this is a mistake, please bump the version in the \`package.json\`." | |
fi |