Skip to content

Updated releaser to one that is not archived #34

Updated releaser to one that is not archived

Updated releaser to one that is not archived #34

Workflow file for this run

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: Generate JWT and Authenticate with GitHub CLI
run: |
client_id="${{ secrets.APP_CLIENT_ID }}"
pem="${{ secrets.APP_PRIVATE_KEY }}"
now=$(date +%s)
iat=$((${now} - 60)) # Issues 60 seconds in the past
exp=$((${now} + 600)) # Expires 10 minutes in the future
b64enc() { openssl base64 | tr -d '=' | tr '/+' '_-' | tr -d '\n'; }
header_json='{
"typ":"JWT",
"alg":"RS256"
}'
# Header encode
header=$( echo -n "${header_json}" | b64enc )
payload_json="{
\"iat\":${iat},
\"exp\":${exp},
\"iss\":\"${client_id}\"
}"
# Payload encode
payload=$( echo -n "${payload_json}" | b64enc )
# Signature
header_payload="${header}"."${payload}"
signature=$(
openssl dgst -sha256 -sign <(echo -n "${pem}") \
<(echo -n "${header_payload}") | b64enc
)
# Create JWT
JWT="${header_payload}"."${signature}"
installations_response=$(curl -X GET \
-H "Authorization: Bearer ${JWT}" \
-H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/app/installations")
access_token_response=$(curl -X POST \
-H "Authorization: Bearer ${JWT}" \
-H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/app/installations/56423252/access_tokens")
echo "${access_token_response}" >> access_token_response.json
access_token=$(echo "${access_token_response}" | jq -r .token)
echo "GH_TOKEN=${access_token}" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v4
- name: Install jq
run: sudo apt-get install jq
- name: Get version from package.json
run: |
VERSION=$(jq -r '.version' package.json)
echo "Version: $VERSION"
echo "VERSION=${VERSION}" >> $GITHUB_ENV
- name: Check if Tag Exists
id: check_tag
run: |
TAG_EXISTS=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/releases" | \
jq --arg VERSION "${{ env.VERSION }}" '.[] | select(.tag_name == $VERSION) | length')
if [ "$TAG_EXISTS" -gt 0 ]; then
echo "Tag ${{ env.VERSION }} already exists. Blocking the PR."
echo "BLOCK_PR=true" >> $GITHUB_ENV
else
echo "Tag ${{ env.VERSION }} does not exist."
echo "BLOCK_PR=false" >> $GITHUB_ENV
fi
- name: Block PR
if: env.BLOCK_PR == 'true'
run: |
curl -X POST -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
-d '{
"body": "Version '${{ env.VERSION }}' already exists; this will overwrite the existing release. If this is a mistake, please bump the version in package.json.",
"event": "REQUEST_CHANGES"
}' \
"https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/reviews"