generate-errors #19
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: Generate Error Codes | |
on: | |
repository_dispatch: | |
types: | |
- generate-errors | |
workflow_dispatch: | |
inputs: | |
commit-message: | |
description: "Commit message for the generated error codes" | |
required: false | |
default: "chore: update error codes" | |
jobs: | |
generate-and-commit: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
id-token: write | |
packages: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up Pnpm | |
uses: pnpm/action-setup@v4 | |
with: | |
package_json_file: package.json | |
run_install: false | |
- name: Set up Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version-file: package.json | |
cache: pnpm | |
cache-dependency-path: pnpm-lock.yaml | |
- name: Install TypeScript dependencies | |
run: pnpm install | |
- name: Generate TypeScript errors | |
run: pnpm generate && pnpm build | |
- name: Generate token | |
id: generate-token | |
uses: actions/create-github-app-token@v1 | |
with: | |
app-id: ${{ secrets.APP_ID }} | |
private-key: ${{ secrets.APP_PRIVATE_KEY }} | |
- name: Prepare and get commit message | |
id: prepare-and-get-commit-message | |
run: | | |
if [[ "${{ github.event_name }}" == "repository_dispatch" ]]; then | |
COMMIT_MESSAGE="${{ github.event.client_payload.commit-message }}" | |
else | |
COMMIT_MESSAGE="${{ github.event.inputs.commit-message }}" | |
fi | |
# Save commit message to a file (if needed) | |
echo "$COMMIT_MESSAGE" > commit-message.txt | |
# Read the file into a variable | |
body=$(cat commit-message.txt) | |
delimiter="$(openssl rand -hex 8)" | |
echo "body<<$delimiter" >> $GITHUB_OUTPUT | |
echo "$body" >> $GITHUB_OUTPUT | |
echo "$delimiter" >> $GITHUB_OUTPUT | |
# Clean up the file | |
rm commit-message.txt | |
- name: Create Pull Request | |
uses: peter-evans/create-pull-request@v6 | |
with: | |
token: ${{ steps.generate-token.outputs.token }} | |
commit-message: | | |
${{ steps.prepare-and-get-commit-message.outputs.body }} | |
title: "Uptake new error codes" | |
body: ":robot: This PR updates the error codes. Merging this PR will trigger a deployment for the TS domain." | |
branch: "update-error-codes" | |
team-reviewers: "api-maintainers" | |
- name: Dry run semantic release | |
run: npx semantic-release --dry-run | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
NPM_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
NODE_TOKEN: ${{ secrets.GITHUB_TOKEN }} |