Use base SHA instead of base branch since the base branch #20
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: Fetch Aviator targets | |
on: | |
pull_request: | |
jobs: | |
fetch-aviator-targets: | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: . | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: '18' | |
cache: 'yarn' | |
- run: yarn install | |
- uses: octokit/[email protected] | |
id: get_pr | |
with: | |
route: GET /repos/${{ github.repository }}/pulls/${{ github.event.number }} | |
owner: octokit | |
repo: request-action | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
- run: | | |
set -euo pipefail | |
PR_NUMBER=${{ github.event.number }} | |
TARGETS_JSON=$(npx nx show projects --affected --base ${{ fromJson(steps.get_pr.outputs.data).base.sha }} --head ${{ github.sha }} --json) | |
echo $TARGETS_JSON | |
echo latest sha: '${{ fromJson(steps.get_pr.outputs.data).base.sha }}' | |
curl -X POST -H "Authorization: Bearer ${{ secrets.AVIATOR_API_TOKEN }}" \ | |
-H "Content-Type: application/json" \ | |
-d '{ | |
"action": "update", | |
"pull_request": { | |
"number": '"$PR_NUMBER"', | |
"repository": {"name": "nx-examples", "org": "aviator-co"}, | |
"affected_targets": '"$TARGETS_JSON"' | |
} | |
}' https://api.aviator.co/api/v1/pull_request/ |