Skip to content

Add Morse Code app #215

Add Morse Code app

Add Morse Code app #215

name: Validate Pull Request
on:
pull_request_target:
types: [opened, synchronize, reopened, labeled]
permissions:
contents: read
pull-requests: write
issues: write
jobs:
validate-metadata:
runs-on: ubuntu-latest
steps:
- name: Debug PR information
run: |
echo "Event: ${{ github.event_name }}"
echo "Action: ${{ github.event.action }}"
echo "PR number: ${{ github.event.number }}"
echo "Base ref: ${{ github.base_ref }}"
echo "Head ref: ${{ github.head_ref }}"
echo "Head SHA: ${{ github.event.pull_request.head.sha }}"
echo "Head repo: ${{ github.event.pull_request.head.repo.full_name }}"
echo "Base repo: ${{ github.repository }}"
- name: Remove validation label if present
if: github.event.action == 'labeled' && github.event.label.name == 'run validation'
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
github.rest.issues.removeLabel({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
name: 'run validation'
})
- name: Checkout base branch to get latest validation script
uses: actions/checkout@v4
with:
ref: ${{ github.base_ref }}
fetch-depth: 0
path: base-repo
- name: Checkout PR code
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
path: pr-repo
- name: Copy validation script from base branch
run: |
mkdir -p pr-repo/.github/scripts/
cp base-repo/.github/scripts/validate-pull-request.js pr-repo/.github/scripts/
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
- name: Change to PR directory and validate
working-directory: pr-repo
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_REPOSITORY: ${{ github.repository }}
GITHUB_EVENT_NAME: ${{ github.event_name }}
GITHUB_EVENT_PATH: ${{ github.event_path }}
GITHUB_BASE_REF: ${{ github.base_ref }}
PR_NUMBER: ${{ github.event.number }}
run: |
# Get changed files using git in the PR directory
CHANGED_FILES=$(git diff --name-only origin/${{ github.base_ref }}...HEAD 2>/dev/null || git diff --name-only HEAD~1 HEAD 2>/dev/null || echo "")
echo "Changed files: $CHANGED_FILES"
# Run the validation script
node .github/scripts/validate-pull-request.js $CHANGED_FILES