-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
185 lines (179 loc) · 7.06 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
name: Host NuGet on GitHub
author: moomiji
description: 'Run the sleet, and push the static nuget feed to github.'
branding:
icon: 'upload-cloud'
color: 'white'
inputs:
base-uri:
description: >
Specify a URI to write to the feed json files instead of the container's URI.
Useful if serving up the content from a different endpoint.
required: true
package-paths:
description: 'Relative paths to individual packages or directories containing packages.'
required: true
on-sleet-pushed:
description: 'Bash commands executed on sleet pushed.'
default: ''
repository-path:
description: >
Relative path under $GITHUB_WORKSPACE/.. to place the nuget feed repository.
The environment variable $FEED_WORKSPACE is set to its absolute path.
Useful if specifying a config.
default: 'GitHub-Hosted'
feed-path:
description: '[Relative path under $FEED_WORKSPACE/ to the output directory of the feed.](https://github.com/emgarten/Sleet/blob/main/doc/client-settings.md#folder-feed-specific-properties)'
default: ''
config:
description: '[Relative path to sleet.json where the source information is contained.](https://github.com/emgarten/Sleet/blob/main/doc/commands.md#push)'
default: 'None'
force:
description: '[Overwrite existing packages.](https://github.com/emgarten/Sleet/blob/main/doc/commands.md#push)'
default: false
skip-existing:
description: '[Skip packages that already exist on the feed.](https://github.com/emgarten/Sleet/blob/main/doc/commands.md#push)'
default: false
commit-message:
description: 'Message to use when committing changes.'
default: '${{ github.repository }}(${{ github.ref_name }})'
commit-author:
description: 'Author name and email address in the format `Display Name <email@address.com>`.'
default: '${{ github.actor }} <${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com>'
commit-user-name:
description: 'User name of the commiter.'
default: 'github-actions[bot]'
commit-user-email:
description: >
User email address of the commiter ( {user.id}+{user.login}@users.noreply.github.com ).
See [users API](https://api.github.com/users/github-actions%5Bbot%5D).
default: '41898282+github-actions[bot]@users.noreply.github.com'
commit-sign:
description: 'Sign commits use `web-flow.gpg` or `commit-user-gpg-key` of your own bot.'
default: false
commit-user-gpg-key:
description: 'GPG private key of your own bot. Defaults to `web-flow.gpg`.'
default: ''
commit-user-gpg-passphrase:
description: 'Passphrase of the GPG key.'
default: ''
squash:
description: 'Indicate whether to squash all commits of the branch.'
default: false
repository:
description: 'Repository name with owner. For example, actions/checkout'
branch:
description: 'The branch name. Otherwise, uses the default branch.'
token:
description: 'Personal access token (PAT) used to fetch and push the repository.'
default: ${{ github.token }}
lfs:
description: 'Whether to download Git-LFS files.'
default: false
outputs:
feed-uri:
description: "Full uri of the feed's root."
value: ${{ steps.verify.outputs.feed-uri }}
runs:
using: "composite"
steps:
-
uses: actions/setup-dotnet@v4
-
uses: actions/checkout@v4
with:
fetch-depth: 0
repository: ${{ inputs.repository }}
token: ${{ inputs.token }}
path: ${{ inputs.repository-path }}
lfs: ${{ inputs.lfs }}
-
id: verify
shell: bash
env:
SLEET_FEED_BASEURI: ${{ inputs.base-uri }}
run: |
mv ${{ inputs.repository-path }} ../
cd ../${{ inputs.repository-path }}
if git rev-parse --verify origin/${{ inputs.branch }}; then
if ${{ inputs.squash }}; then
echo "exist-branch=squash" | tee -a $GITHUB_OUTPUT
git checkout ${{ inputs.branch }}
git checkout --orphan temp-${{ inputs.branch }}
git branch -d ${{ inputs.branch }}
git branch -m ${{ inputs.branch }}
else
echo "exist-branch=true" | tee -a $GITHUB_OUTPUT
git checkout ${{ inputs.branch }}
fi
else
echo "exist-branch=false" | tee -a $GITHUB_OUTPUT
git checkout --orphan ${{ inputs.branch }}
git rm -rf .
fi
cd ${GITHUB_WORKSPACE}/../${{ inputs.repository-path }}
echo "feed-workspace=$(pwd)" | tee -a $GITHUB_OUTPUT
echo "feed-uri=${SLEET_FEED_BASEURI%/}/index.json" | tee -a $GITHUB_OUTPUT
-
shell: bash
env:
PACKAGE_PATHS: ${{ inputs.package-paths }}
SLEET_FEED_TYPE: local
SLEET_FEED_BASEURI: ${{ inputs.base-uri }}
SLEET_FEED_PATH: ${{ steps.verify.outputs.feed-workspace }}/${{ inputs.feed-path }}
FEED_WORKSPACE: ${{ steps.verify.outputs.feed-workspace }}
run: |
dotnet tool install -g sleet
sleet push ${PACKAGE_PATHS} \
${{ inputs.force && '--force' || '' }} \
${{ inputs.skip-existing && '--skip-existing' || '' }} \
--config ${{ inputs.config }}
-
shell: bash
env:
SLEET_FEED_TYPE: local
SLEET_FEED_BASEURI: ${{ inputs.base-uri }}
SLEET_FEED_PATH: ${{ steps.verify.outputs.feed-workspace }}/${{ inputs.feed-path }}
FEED_WORKSPACE: ${{ steps.verify.outputs.feed-workspace }}
run: ${{ inputs.on-sleet-pushed }}
-
if: inputs.commit-sign == 'true' && inputs.commit-user-gpg-key != ''
id: gpg
uses: crazy-max/ghaction-import-gpg@v6
with:
workdir: ${{ steps.verify.outputs.feed-workspace }}
gpg_private_key: ${{ inputs.commit-user-gpg-key }}
passphrase: ${{ inputs.commit-user-gpg-passphrase }}
git_user_signingkey: true
git_commit_gpgsign: true
-
shell: bash
run: |
cd ${{ steps.verify.outputs.feed-workspace }}
git config --local user.name "${{ inputs.commit-user-name }}"
git config --local user.email "${{ inputs.commit-user-email }}"
git add .
git commit \
-m "${{ inputs.commit-message }}" \
-m "- sha: ${{ github.sha }}" \
-m "- run: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" \
--author="${{ inputs.commit-author }}" \
${{ steps.gpg.outputs.keyid != '' && '-S' || '' }}
if ${{ steps.verify.outputs.exist-branch == 'squash' }}; then
git branch --set-upstream-to=origin/${{ inputs.branch }}
fi
if ${{ steps.verify.outputs.exist-branch == 'true' }}; then
git pull origin ${{ inputs.branch }} --rebase
fi
-
uses: ad-m/github-push-action@master
with:
repository: ${{ inputs.repository }}
branch: ${{ inputs.branch }}
github_token: ${{ inputs.token }}
directory: ${{ steps.verify.outputs.feed-workspace }}
force_with_lease: ${{ steps.verify.outputs.exist-branch == 'squash' }}
-
if: always()
shell: bash
run: rm -rf ${{ steps.verify.outputs.feed-workspace }}