-
Notifications
You must be signed in to change notification settings - Fork 1
62 lines (52 loc) · 2.58 KB
/
get-values.yaml
File metadata and controls
62 lines (52 loc) · 2.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
name: Get Values
on:
workflow_call:
outputs:
new-dependabot-sha:
description: BUILD_HASH
value: ${{ jobs.get-values.outputs.new-dependabot-sha }}
dependabot-commit-created:
description: whether or not a commit was created on a dependabot branch
value: ${{ jobs.get-values.outputs.dependabot-commit-created }}
pr-short-num:
description: the last two digits of the PR number (to be used for fixed width naming, like Pulumi stacks)
value: ${{ jobs.get-values.outputs.pr-short-num }}
env:
PYTHONUNBUFFERED: True
permissions:
contents: write # needed to push commit of new devcontainer hash for dependabot PRs
jobs:
get-values:
runs-on: ubuntu-24.04
timeout-minutes: 2
outputs:
new-dependabot-sha: ${{ steps.update-hash.outputs.new-sha }}
dependabot-commit-created: ${{ steps.update-hash.outputs.commit-created }}
pr-short-num: ${{ steps.find-pr-num.outputs.number }}
steps:
- name: Display full GitHub context
run: |
jq . <<'JSON'
${{ toJSON(github) }}
JSON
- name: Checkout code
uses: actions/checkout@v6.0.2
with:
persist-credentials: false
- name: Update Devcontainer Hash
if: ${{ github.actor == 'dependabot[bot]' && github.event_name == 'push' }}
id: update-hash
uses: ./.github/actions/update-devcontainer-hash
with:
branch: ${{ github.ref_name }}
- name: Get the PR number
if: ${{ github.event_name == 'pull_request' || github.event_name == 'merge_group' }}
id: find-pr-num
# Based on https://github.com/actions/checkout/issues/58#issuecomment-847922894
run: |
[[ '${{ github.event_name }}' = 'pull_request' ]] && full_number=${{ github.event.number }}
# example message in merge group context: "Merge pull request #10 from org-name/branch-name\n\ncommit message"
[[ '${{ github.event_name }}' = 'merge_group' ]] && message='${{ github.event.merge_group.head_commit.message }}' && echo Extracting from $message && number_and_following_text=${message##*#} && full_number=${number_and_following_text%%[!0-9]*}
short_number=${full_number:${#full_number}<2?0:-2} # only use the last two digits so that the stack name is no more than 7 characters and doesn't get too long. Based on https://stackoverflow.com/questions/19858600/accessing-last-x-characters-of-a-string-in-bash
echo number=$(echo $short_number) >> $GITHUB_OUTPUT
echo "PR number extracted as $full_number and truncated to $short_number"