-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
102 lines (95 loc) · 3.64 KB
/
action.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
name: 'Git Tags to Workflow Dispatch'
description: 'Automatically populate the workflow dispatch options with available tags from the repo'
author: '64J0'
branding:
icon: 'check-circle'
color: 'blue'
inputs:
values-to-take:
description: >
In order to avoid presenting very old tags at the workflow options, this input let's you
specify how many tags to take, considering the order starting from the new tags to the
old tags. If you don't specify this value, it will take all the tags.
default: '-1'
workflow-file-name:
description: >
Specify the target workflow file name that must live under `.github/workflows/`.
workflow-yaml-key:
description: >
Specify the workflow YAML key that will be updated.
pull-request:
description: >
TODO. Set the value 'false' if you prefer that the workflow change is commited directly
instead of creating a pull request that you can manually verify.
default: 'true'
github-token:
description: >
A GitHub token with permissions:
- contents: write
- pull-requests: write
Necessary for https://github.com/marketplace/actions/create-pull-request#action-inputs.
Also necessary: https://github.com/marketplace/actions/create-pull-request#workflow-permissions.
git-tags:
description: >
The repository tags.
base:
description: >
Sets the pull request base branch.
Necessary due to:
- https://github.com/peter-evans/create-pull-request/blob/v6.1.0/src/create-pull-request.ts#L98
runs:
using: 'composite'
steps:
# xxx necessary to have access to the .github/workflows directory
- name: Checkout repo
uses: actions/checkout@v4
- name: Add HELPER_PATH
shell: bash
run: echo "HELPER_PATH=${GITHUB_SHA}-fsharp-program" >> "${GITHUB_ENV}"
# TODO automate the update of the tag for download
- name: Download the self-contained .NET program
shell: bash
env:
PACKAGE_URL: 'https://github.com/FsharpGHActions/git-tag-to-workflow-dispatch/releases/download/v0.0.017/fsharp-program.tar.gz'
run: wget -O "${HELPER_PATH}.tar.gz" "${PACKAGE_URL}"
- name: Uncompress the .NET program
shell: bash
run: |
mkdir "${HELPER_PATH}/"
tar -xf "${HELPER_PATH}.tar.gz" -C "${HELPER_PATH}/"
- name: Run the .NET program
shell: bash
env:
VALUES_TO_TAKE: ${{ inputs.values-to-take }}
WORKFLOW_KEY: ${{ inputs.workflow-yaml-key }}
GIT_TAGS: ${{ inputs.git-tags }}
run: ./${HELPER_PATH}/out/Main "${GIT_TAGS}"
- name: Merge the workflows
uses: mikefarah/yq@master
env:
WORKFLOW_FILE_NAME: ${{ inputs.workflow-file-name }}
with:
cmd: yq -i '. * load("./workflow.new.yml")' ".github/workflows/${WORKFLOW_FILE_NAME}"
- name: Debug -> Print the new workflow file
shell: bash
env:
WORKFLOW_FILE_NAME: ${{ inputs.workflow-file-name }}
run: cat ".github/workflows/${WORKFLOW_FILE_NAME}"
- name: Clean action
shell: bash
run: |
rm "./workflow.new.yml"
rm "./${HELPER_PATH}.tar.gz"
rm -rf "./${HELPER_PATH}/"
- name: Create pull request
# if: ${{ inputs.pull-request }} # TODO
uses: peter-evans/create-pull-request@v6
with:
token: ${{ inputs.github-token }}
base: ${{ inputs.base }}
branch-suffix: timestamp
branch: git-tag-to-workflow-dispatch
commit-message: |
chore: automated git tags to workflow dispatch
this commit is updating the workflow dispatch (github actions) options autonomously
with the tags from this repository