Compare commits

...

4 Commits

Author SHA1 Message Date
Jonathan Hood
26c2043bf3
Merge 357a18e2c6 into f3ceefdc7e 2026-04-13 16:20:36 +00:00
Sascha Bratton
f3ceefdc7e
fix: use rev-parse instead of branch --show-current for older git compat (#303) 2026-04-10 17:44:48 -04:00
Lucas Servén Marín
61f87a10cd
chore: fix GitHub spelling in logs (#278)
* chore: fix GitHub spelling in logs

* fix: rebuild dist

---------

Co-authored-by: Sascha Bratton <sascha@queen.one>
2026-03-25 12:27:15 -04:00
Jonathan Hood
357a18e2c6
docs: document dealing with chained dependencies 2024-04-05 10:13:47 -05:00
4 changed files with 62 additions and 8 deletions

View File

@ -315,6 +315,60 @@ jobs:
</details>
<details>
<summary>Execute a job in a dependency chain even if a dependency is skipped</summary>
```yaml
jobs:
# JOB to run change detection
changes:
runs-on: ubuntu-latest
# Required permissions
permissions:
pull-requests: read
# Set job outputs to values from filter step
outputs:
backend: ${{ steps.filter.outputs.backend }}
frontend: ${{ steps.filter.outputs.frontend }}
steps:
# For pull requests it's not necessary to checkout the code
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
backend:
- 'backend/**'
frontend:
- 'frontend/**'
# JOB to build and test backend code
# Should execute before the frontend builds (if needed)
backend:
needs: changes
if: ${{ needs.changes.outputs.backend == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- ...
# JOB to build and test frontend code
# Should execute only after backend rebuilds (if needed)
frontend:
needs: [changes, backend]
if: |
${{
!cancelled() &&
needs.changes.outputs.frontend == 'true' &&
(needs.backend.result == 'success' || needs.backend.result == 'skipped')
}}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- ...
```
</details>
### Change detection workflows
<details>

8
dist/index.js vendored
View File

@ -363,8 +363,8 @@ exports.listAllFilesAsAdded = listAllFilesAsAdded;
async function getCurrentRef() {
core.startGroup(`Get current git ref`);
try {
const branch = (await (0, exec_1.getExecOutput)('git', ['branch', '--show-current'])).stdout.trim();
if (branch) {
const branch = (await (0, exec_1.getExecOutput)('git', ['rev-parse', '--abbrev-ref', 'HEAD'])).stdout.trim();
if (branch && branch !== 'HEAD') {
return branch;
}
const describe = await (0, exec_1.getExecOutput)('git', ['describe', '--tags', '--exact-match'], { ignoreReturnCode: true });
@ -640,7 +640,7 @@ async function getChangedFiles(token, base, ref, initialFetchDepth) {
// At the same time we don't want to fetch any code from forked repository
throw new Error(`'token' input parameter is required if action is triggered by 'pull_request_target' event`);
}
core.info('Github token is not available - changes will be detected using git diff');
core.info('GitHub token is not available - changes will be detected using git diff');
const baseSha = (_a = github.context.payload.pull_request) === null || _a === void 0 ? void 0 : _a.base.sha;
const defaultBranch = (_b = github.context.payload.repository) === null || _b === void 0 ? void 0 : _b.default_branch;
const currentRef = await git.getCurrentRef();
@ -710,7 +710,7 @@ async function getChangedFilesFromGit(base, head, initialFetchDepth) {
}
// Uses github REST api to get list of files changed in PR
async function getChangedFilesFromApi(token, pullRequest) {
core.startGroup(`Fetching list of changed files for PR#${pullRequest.number} from Github API`);
core.startGroup(`Fetching list of changed files for PR#${pullRequest.number} from GitHub API`);
try {
const client = github.getOctokit(token);
const per_page = 100;

View File

@ -166,8 +166,8 @@ export async function listAllFilesAsAdded(): Promise<File[]> {
export async function getCurrentRef(): Promise<string> {
core.startGroup(`Get current git ref`)
try {
const branch = (await getExecOutput('git', ['branch', '--show-current'])).stdout.trim()
if (branch) {
const branch = (await getExecOutput('git', ['rev-parse', '--abbrev-ref', 'HEAD'])).stdout.trim()
if (branch && branch !== 'HEAD') {
return branch
}

View File

@ -107,7 +107,7 @@ async function getChangedFiles(token: string, base: string, ref: string, initial
// At the same time we don't want to fetch any code from forked repository
throw new Error(`'token' input parameter is required if action is triggered by 'pull_request_target' event`)
}
core.info('Github token is not available - changes will be detected using git diff')
core.info('GitHub token is not available - changes will be detected using git diff')
const baseSha = github.context.payload.pull_request?.base.sha
const defaultBranch = github.context.payload.repository?.default_branch
const currentRef = await git.getCurrentRef()
@ -194,7 +194,7 @@ async function getChangedFilesFromGit(base: string, head: string, initialFetchDe
// Uses github REST api to get list of files changed in PR
async function getChangedFilesFromApi(token: string, pullRequest: PullRequest): Promise<File[]> {
core.startGroup(`Fetching list of changed files for PR#${pullRequest.number} from Github API`)
core.startGroup(`Fetching list of changed files for PR#${pullRequest.number} from GitHub API`)
try {
const client = github.getOctokit(token)
const per_page = 100