-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathaction.yml
More file actions
79 lines (65 loc) · 3.91 KB
/
action.yml
File metadata and controls
79 lines (65 loc) · 3.91 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
name: autocopr
description: Check or update RPM spec files to the project's latest version released on Github
branding:
icon: 'arrow-up-circle'
color: 'blue'
inputs:
mode:
description: "The mode the action should run in. Options:
- `push`: Automated updates. If any specfile is outdated, write new specfiles, make a commit for each with an associated tag, and push it to the repo. Requires `contents: write` permissions on the GITHUB_TOKEN to allow for pushes to a repo. See the `README.md` to learn how to start a COPR build based on these commits being pushed.
- `check`: Manual updates. The job succeeds if all specfiles are up to date and fails if any are outdated. This mode does not write new files or push any updates - updating the specfile requires manual action. This mode is more secure since the action is read-only.
- `dry-run`: Intended for testing. The job is read-only and always succeeds, no matter if the specfiles are up to date or not. Like all other modes, it logs to stdout which files are up to date or not.
There are other modes you can use here (`update`), but they're only intended for local use. You can read about them in the README under the `mode` flag, and you're allowed to use them here. If you find a use for them in CI, raise an issue and I'll document them here!"
required: true
root_loc:
description: "A path to a folder, relative to the repo root, where the action will look for spec files. This searches recursively. Defaults to checking the entire repo."
default: '.' # Defaults to the root of the repo
ignore:
description: "A list of spec filepaths relative to root_loc to ignore."
verbose:
description: "If the script should log additional information to stdout. Options: `true` or `false` (default)."
default: "false"
runs:
using: composite
steps:
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: '3.14'
# FIXME: Caching outside of the directory is not supported right now.
# I could work around it, but frankly I'm only installing requests, it isn't worth it
# Implement when the issue is resolved
# https://github.com/actions/setup-python/issues/361
# cache: 'pip'
# cache-dependency-path: "${{ github.action_path }}/requirements.txt"
- name: Install dependencies
shell: bash
working-directory: ${{ github.action_path }}
# https://www.b-list.org/weblog/2023/dec/07/pip-install-safely/ for logic behind the flags used here
run: "python -m pip install --require-hashes --no-deps --only-binary :all: -r requirements.txt"
- name: Set git user to github-actions[bot]
shell: bash
run: |
git config --local user.name "github-actions[bot]"
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Cache GraphQL API IDs
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
with:
path: ${{ inputs.root_loc }}/graphql_id_cache.json
# This key is overkill - we really only need to update the
# cache when a *new* spec file is added, not when *any* spec
# file changes. However, this seems to be the easiest way
# to achieve that from within Actions.
key: autocopr-graphql-ids-${{ hashFiles(format('{0}/**/*.spec', inputs.root_loc)) }}
# Make sure even if the specs change it grabs the old cache
# to start from! Entries are never invalidated, only added
restore-keys: autocopr-graphql-ids
- name: Check and update spec files
shell: bash
run: "${ACTIONS_FOLDER}/action.sh"
env:
GITHUB_TOKEN: ${{ github.token }}
ACTIONS_FOLDER: ${{ github.action_path }}
ROOT_LOC: ${{ github.workspace }}/${{ inputs.root_loc }}
MODE: ${{ inputs.mode }}
VERBOSE: ${{ inputs.verbose }}
IGNORE: ${{ inputs.ignore }}