Skip to content

Commit

Permalink
Add some composite actions (#18)
Browse files Browse the repository at this point in the history
Mimicking the set-up we have at
https://github.com/UCL-MIRSG/.github/tree/main/actions. Required for
@r-roker-ucl to add issues/PRs to project boards.
  • Loading branch information
paddyroddy authored Jul 5, 2024
1 parent 79d60db commit 58addb3
Show file tree
Hide file tree
Showing 15 changed files with 358 additions and 53 deletions.
8 changes: 4 additions & 4 deletions .github/ISSUE_TEMPLATE/agile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ body:
label: Definition of Done / Acceptance Criteria
description: What can someone see/do when this task is done.
placeholder: >-
The export data is available in the xxx format,
including age of the patient at the time of imaging...
The export data is available in the xxx format, including age of the
patient at the time of imaging...
validations:
required: true
- type: textarea
Expand All @@ -33,8 +33,8 @@ body:
attributes:
label: Dependencies
description: >-
Enter the github issue number(s) that the
requirement is dependent on, in the form `#1`
Enter the github issue number(s) that the requirement is dependent on,
in the form `#1`
placeholder: "#1"
validations:
required: false
Expand Down
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/workstream.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ body:
label: Child issues
description: What issues need to be completed for this issue to be done
placeholder: >-
The export data is available in the xxx format,
including age of the patient at the time of imaging...
The export data is available in the xxx format, including age of the
patient at the time of imaging...
validations:
required: false
21 changes: 21 additions & 0 deletions .github/workflows/links.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
name: Links

on:
push:
branches:
- main
- renovate/**
pull_request:

jobs:
links:
runs-on: ubuntu-latest
timeout-minutes: 2
steps:
- name: Checkout source
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4

- uses: ./actions/links
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
20 changes: 20 additions & 0 deletions .github/workflows/linting.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Linting

on:
push:
branches:
- main
- renovate/**
pull_request:

jobs:
linting:
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4

- uses: ./actions/linting
with:
pre-commit-config: ./.pre-commit-config.yaml
34 changes: 0 additions & 34 deletions .github/workflows/linting.yml

This file was deleted.

51 changes: 51 additions & 0 deletions .github/workflows/tags.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
name: Bump Version Tag

on:
push:
branches:
- main
paths:
- "**/*"
- "!**/*.json"
- "!**/*.json5"
- "!**/*.md"
- "!.github/**"
- "!.gitignore"
- "!.pre-commit-config.yaml"
workflow_dispatch:

jobs:
tags:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout source
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
with:
fetch-depth: 0

- name: Bump version and push tag
id: bump-version
# yamllint disable-line rule:line-length
uses: anothrNick/github-tag-action@afe4b67b57b8ab0908e4767109a5342003639e2e # v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
WITH_V: true

- name: Extract major tag
id: extract-major
run: >-
echo major_tag=$(echo ${{ steps.bump-version.outputs.new_tag }} | cut
-d'.' -f1) >> $GITHUB_OUTPUT
# this is done manually as need a non-annotated tag
# TODO: replace with https://github.com/actions/publish-action
- name: Update major tag
run: |-
git config user.name github-actions
git config user.email [email protected]
git tag --force ${{ steps.extract-major.outputs.major_tag }} \
${{ steps.bump-version.outputs.new_tag }}
git push origin ${{ steps.extract-major.outputs.major_tag }} --force
44 changes: 41 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,30 +1,65 @@
---
repos:
- repo: https://github.com/adrienverge/yamllint
rev: v1.33.0
rev: v1.35.1
hooks:
- id: yamllint
args:
- >-
--config-data={
extends: default,
rules: {
anchors: enable,
braces: {
forbid: non-empty
},
brackets: {
forbid: non-empty
},
colons: enable,
commas: enable,
comments: {
min-spaces-from-content: 1
},
comments-indentation: enable,
document-end: disable,
document-start: enable,
empty-lines: enable,
empty-values: disable,
float-values: enable,
hyphens: enable,
indentation: enable,
key-duplicates: enable,
key-ordering: disable,
line-length: enable,
new-line-at-end-of-file: enable,
new-lines: enable,
octal-values: enable,
quoted-strings: {
quote-type: double,
required: only-when-needed
},
trailing-spaces: enable,
truthy: {
check-keys: false
}
}
}
- --strict
- repo: https://github.com/crate-ci/typos
rev: v1.16.26
rev: v1.22.9
hooks:
- id: typos
args:
- --force-exclude
- --hidden
- --locale=en-gb
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.38.0
hooks:
- id: markdownlint-fix
args:
- --dot
- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.5.4
hooks:
Expand All @@ -33,8 +68,11 @@ repos:
rev: v3.1.0
hooks:
- id: prettier
args:
- --prose-wrap=always
- --quote-props=as-needed
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v4.6.0
hooks:
- id: check-added-large-files
- id: check-case-conflict
Expand Down
5 changes: 5 additions & 0 deletions actions/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Composite Actions

A set of
[composite actions](https://docs.github.com/en/actions/creating-actions/creating-a-composite-action)
that can be called by other workflows in the ARC organisation.
55 changes: 55 additions & 0 deletions actions/add-to-project/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# add-to-project

This action can be used in the following manner to add issues to project boards:

```yaml
jobs:
add-issue-to-project:
runs-on: ubuntu-latest
steps:
- uses: UCL-ARC/.github/actions/add-to-project@vx
with:
app-id: ${{ secrets.APP_ID }}
app-pem: ${{ secrets.APP_PEM }}
project-url: project_board_url
```
where `x` is the `major` version of the action, and `project_board_url` is the
full URL of the project board to which the repository's issues should be added.
If a particular label should trigger the action to go to a different project
board then one may specify the `label` input as follows:

```yaml
jobs:
add-issue-to-project:
runs-on: ubuntu-latest
steps:
- uses: UCL-ARC/.github/actions/add-to-project@vx
with:
app-id: ${{ secrets.APP_ID }}
app-pem: ${{ secrets.APP_PEM }}
label: label_name
project-url: project_board_url
```

where `label_name` is a
[comma-separated list of labels](https://github.com/actions/add-to-project/tree/main?tab=readme-ov-file#inputs).
Lastly, `label-operator` may be used to specify the logical operator to be used
when checking for the presence of labels. The default value is `OR`, but may be
configured as follows:

```yaml
jobs:
add-issue-to-project:
runs-on: ubuntu-latest
steps:
- uses: UCL-ARC/.github/actions/add-to-project@vx
with:
app-id: ${{ secrets.APP_ID }}
app-pem: ${{ secrets.APP_PEM }}
label: label_name
label-operator: AND
project-url: project_board_url
```

where `label-operator` may be set to `AND`, `NOT` or `OR`.
44 changes: 44 additions & 0 deletions actions/add-to-project/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
name: Add Issues to Project
description: Add issues to the GitHub project board

inputs:
app-id:
description: Application ID
required: true

app-pem:
description: Application private key
required: true

labeled:
description: Label to filter issues by
default: ""

label-operator:
description: Operator to filter issues by label
default: OR

project-url:
description: URL of the project board to add issues to
required: true

runs:
using: composite
steps:
- name: Generate token
id: generate-token
# yamllint disable-line rule:line-length
uses: actions/create-github-app-token@ad38cffc07bac6e3857755914c4c88bfd2db4da4 # v1
with:
app-id: ${{ inputs.app-id }}
private-key: ${{ inputs.app-pem }}

- name: Get project data
# yamllint disable-line rule:line-length
uses: actions/add-to-project@244f685bbc3b7adfa8466e08b698b5577571133e # v1.0.2
with:
github-token: ${{ steps.generate-token.outputs.token }}
label-operator: ${{ inputs.label-operator }}
labeled: ${{ inputs.labeled }}
project-url: ${{ inputs.project-url }}
30 changes: 30 additions & 0 deletions actions/links/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# links

This action can be used in the following manner:

```yaml
jobs:
links:
runs-on: ubuntu-latest
timeout-minutes: 2
steps:
- uses: UCL-ARC/.github/actions/links@vx
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
```
where `x` is the `major` version of the action. If custom link checking is
required, one can add custom inputs through `lychee-args`, i.e.:

```yaml
jobs:
linting:
runs-on: ubuntu-latest
steps:
- uses: UCL-ARC/.github/actions/linting@vx
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
lychee-args:
--base . --verbose --no-progress './**/*.md' './**/*.html'
'./**/*.rst'
```
Loading

0 comments on commit 58addb3

Please sign in to comment.