generated from actions/typescript-action
-
Notifications
You must be signed in to change notification settings - Fork 1
77 lines (69 loc) · 2.37 KB
/
_souji.yml
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
on:
workflow_call:
inputs:
branch-names:
description:
'List of branch(ref) names with caches to be deleted (e.g., `main
refs/pull/123/merge refs/tags/1.0.0`)'
required: false
type: string
dry-run:
description: 'If `true`, dry-run caches deletion.'
default: false
required: false
type: boolean
secrets:
repo-token:
description: 'The GitHub token used to manage repository action cache'
required: false
permissions: {}
env:
HERE: '4m-mazi/souji-action/.github/workflows/_souji.yml'
jobs:
souji:
runs-on: ubuntu-latest
permissions:
actions: write
contents: read
steps:
- id: get-path
name: 'Get path of caller workflow'
env:
WORKFLOW_REF: ${{ github.workflow_ref }}
REPOSITORY: ${{ github.repository }}
run: |
result=$(sed -e "s|^$REPOSITORY/||" -e 's|@refs/.*||' <<< "$WORKFLOW_REF")
echo "result=$result" >> "$GITHUB_OUTPUT"
- name: 'Checkout caller workflow'
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
sparse-checkout: |
${{ steps.get-path.outputs.result }}
sparse-checkout-cone-mode: false
- id: escape
name: 'Escape yq command'
run: |
result=$(
sed -e 's/"/\\"/g' << 'EOF'
yq '[.jobs.*.uses | select(tag == "!!str" and test("^${{ env.HERE }}@"))][0] | sub("^${{ env.HERE }}@", "")' ${{ steps.get-path.outputs.result }}
EOF
)
echo "result=$result" >> "$GITHUB_OUTPUT"
- id: get-ref
name: 'Get ref of souji-workflow'
uses: docker://mikefarah/yq:4.44.6-githubaction@sha256:aafcb67a004db4dbfcfae6e09cc6db13be1ffdfb2f5940466e05893b6c30301d
with:
args: |-
"${{ steps.escape.outputs.result }}"
- name: 'Checkout souji-action'
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
repository: 4m-mazi/souji-action
ref: ${{ steps.get-ref.outputs.result }}
path: 'souji-action'
- name: 'Run souji-action'
uses: ./souji-action/
with:
repo-token: ${{ secrets.repo-token || github.token }}
branch-names: ${{ inputs.branch-names }}
dry-run: ${{ inputs.dry-run }}