[ci] Upgrade to actions/checkout@v3

The v2 action depends on deprecated Node.js 12, as indicated by warning
from GitHub Actions:

    Node.js 12 actions are deprecated. For more information see: [1].
    Please update the following actions to use Node.js 16:
      actions/checkout@v2

(See [2] for an example.)

Upgrade to actions/checkout@v3 to silence the warning.

Unfortunately this new version has a very confusing policy for default
checkout ref: "[...] the last merge commit of the pull request merge
branch". There does not appear to be a convenient way to fall back to
the v2 behavior.

Add some conditional logic to resolve the HEAD of the right branch
whether it's a schedule, push or pull_request event.

[1] https://github.blog/changelog/2022-09-22-github-actions-all-actions-will-begin-running-on-node16-instead-of-node12/.
[2] https://github.com/include-what-you-use/include-what-you-use/actions/runs/3718310359
This commit is contained in:
Kim Gräsman 2022-12-18 13:16:39 +01:00
parent 5a990cdae7
commit 44fa8c7bd0
1 changed files with 14 additions and 2 deletions

View File

@ -38,8 +38,20 @@ jobs:
libclang$LLVM_TAG-dev \
clang$LLVM_TAG
- name: Check out default branch
uses: actions/checkout@v2
- name: Select checkout ref (PR)
if: github.event_name == 'pull_request'
run: |
echo "IWYU_CHECKOUT_REF=${{github.event.pull_request.head.sha}}" >> $GITHUB_ENV
- name: Select checkout ref (push/schedule)
if: github.event_name == 'push' || github.event_name == 'schedule'
run: |
echo "IWYU_CHECKOUT_REF=${{github.sha}}" >> $GITHUB_ENV
- name: Check out branch
uses: actions/checkout@v3
with:
ref: ${{env.IWYU_CHECKOUT_REF}}
- name: Build include-what-you-use
run: |