-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathaction.yml
163 lines (161 loc) · 5.94 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
name: 'conda subchannel'
description: 'Republish a subset of an existing conda channel'
inputs:
subchannel-name:
description: "Name of the subchannel that will be created"
required: false
default: "subchannel"
served-at:
description: "URL where the subchannel files will be uploaded to"
required: false
default: ""
channel:
description: "Source conda channel"
required: true
repodata-fn:
description: "Source repodata file to process from channel"
required: false
default: "repodata.json"
base-url:
description: "URL where the packages will be available. Defaults to the base URL for 'channel'"
required: false
default: ""
subdirs:
description: "List of platforms to support, space separated. Defaults to linux-64. Noarch is always included"
required: false
default: "linux-64"
after:
description: "Timestamp as ts:<float> or date as YYYY-[MM[-DD[-HH[-MM[-SS]]]]]"
required: false
default: ""
before:
description: "Timestamp as ts:<float> or date as YYYY-[MM[-DD[-HH[-MM[-SS]]]]]"
required: false
default: ""
keep-trees:
description: "Keep packages matching these specs and their dependencies. Space separated"
required: false
default: ""
keep-specs:
description: "Keep packages matching these specs only. Space separated"
required: false
default: ""
prune-specs:
description: "Remove the distributions (within the corresponding package name) that do not match these specs. Space separated"
required: false
default: ""
remove-specs:
description: "Remove packages matching these specs. Space separated"
required: false
default: ""
gh-pages-branch:
description: "Name of the branch for the GH Pages deployment. Set to `''` to disable."
required: false
default: gh-pages
outputs:
output-directory:
description: "Path to the directory containing the subchannel data"
value: ${{ steps.validate.outputs.output-directory }}
runs:
using: "composite"
steps:
- name: Check Runner OS
if: ${{ runner.os != 'Linux' }}
shell: bash
run: |
echo "::error title=⛔ error hint::Only Linux is supported"
exit 1
- name: Validate inputs
shell: bash
id: validate
run: |
# Validate inputs
if [[
"${{ inputs.after }}" == ""
&& "${{ inputs.before }}" == ""
&& "${{ inputs.keep-trees }}" == ""
&& "${{ inputs.keep-specs }}" == ""
&& "${{ inputs.prune-specs }}" == ""
&& "${{ inputs.remove-specs }}" == ""
]]; then
echo "::error title=⛔ error hint::At least one of `after`, `before`, `keep-trees`, `keep-specs` or `remove-specs` must be set"
exit 1
fi
mkdir -p "${{ runner.temp }}/subchannel"
echo "output-directory=${{ runner.temp }}/${{ inputs.subchannel-name }}" >> $GITHUB_OUTPUT
- uses: prefix-dev/setup-pixi@632d17935141ec801697e2c359784b878adecbbe # v0.6.0
with:
environments: default
manifest-path: ${{ github.action_path }}/pyproject.toml
- name: Setup project
shell: bash
run: |
# Install project
cd "${{ github.action_path }}"
SETUPTOOLS_SCM_PRETEND_VERSION=0.1 pixi run --environment default python -mpip install --no-deps .
- name: Prepare command
shell: pixi run --manifest-path "${{ github.action_path }}/pyproject.toml" --environment default python -u {0}
run: |
# Prepare and run conda subchannel
import subprocess
import sys
args = [
"--channel",
"""${{ inputs.channel }}""".strip(),
"--output",
"${{ steps.validate.outputs.output-directory }}",
"--repodata-fn",
"""${{ inputs.repodata-fn }}""".strip(),
]
served_at = """${{ inputs.served-at }}""".strip()
if served_at:
args += ["--served-at", served_at]
base_url = """${{ inputs.base-url }}""".strip()
if base_url:
args += ["--base-url", base_url]
after = """${{ inputs.after }}""".strip()
if after:
args += ["--after", after]
before = """${{ inputs.before }}""".strip()
if before:
args += ["--before", before]
subdirs = """${{ inputs.subdirs }}""".strip()
for subdir in subdirs.split():
args += ["--subdir", subdir]
keep_trees = """${{ inputs.keep-trees }}""".strip()
for spec in keep_trees.split():
args += ["--keep-tree", spec]
keep_specs = """${{ inputs.keep-specs }}""".strip()
for spec in keep_specs.split():
args += ["--keep", spec]
prune_specs = """${{ inputs.prune-specs }}""".strip()
for spec in prune_specs.split():
args += ["--prune", spec]
remove_specs = """${{ inputs.remove-specs }}""".strip()
for spec in remove_specs.split():
args += ["--remove", spec]
print("Running: conda subchannel", *args)
p = subprocess.run(
[sys.executable, "-mconda", "subchannel", *args],
)
sys.exit(p.returncode)
- name: Decide deployment
id: decide
shell: bash
run: |
# Decide if we deploy to GH Pages or not
if [[ "${{ inputs.gh-pages-branch }}" != "" && "${{ github.ref }}" == "refs/heads/main" ]]; then
echo "deploy=true" >> $GITHUB_OUTPUT
else
echo "Will skip deployment to GH Pages."
echo "deploy=false" >> $GITHUB_OUTPUT
fi
- uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4.0.0
if: steps.decide.outputs.deploy == 'true'
with:
github_token: ${{ github.token }}
publish_branch: ${{ inputs.gh-pages-branch }}
publish_dir: ${{ steps.validate.outputs.output-directory }}
user_name: 'github-actions[bot]'
user_email: 'github-actions[bot]@users.noreply.github.com'
enable_jekyll: false