Skip to content

Commit

Permalink
chore: Update GitHub Actions workflow to handle branch not found error
Browse files Browse the repository at this point in the history
  • Loading branch information
nishimotz committed Jun 5, 2024
1 parent d11f107 commit 7daae3a
Showing 1 changed file with 21 additions and 12 deletions.
33 changes: 21 additions & 12 deletions .github/workflows/update-readme.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,27 @@ jobs:
uses: actions/github-script@v5
with:
script: |
const result = await github.rest.repos.compareCommits({
owner: context.repo.owner,
repo: context.repo.repo,
base: 'master',
head: 'update-readme-${{ github.run_number }}'
});
if (result.data.files.length > 0) {
console.log("Changes detected");
core.setOutput("changes_detected", "true");
} else {
console.log("No changes detected");
core.setOutput("changes_detected", "false");
try {
const result = await github.rest.repos.compareCommits({
owner: context.repo.owner,
repo: context.repo.repo,
base: 'master',
head: 'update-readme-${{ github.run_number }}'
});
if (result.data.files.length > 0) {
console.log("Changes detected");
core.setOutput("changes_detected", "true");
} else {
console.log("No changes detected");
core.setOutput("changes_detected", "false");
}
} catch (error) {
if (error.status === 404) {
console.log("Branch not found, no changes detected");
core.setOutput("changes_detected", "false");
} else {
throw error;
}
}
- name: Commit README.md updates
Expand Down

0 comments on commit 7daae3a

Please sign in to comment.