-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from neicnordic/feature/aggregate-action
Add docs aggregation github action
- Loading branch information
Showing
3 changed files
with
79 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
name: "Aggregate documentation" | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
repository: | ||
description: 'Repository to aggregate documentation from' | ||
required: true | ||
default: "neicnordic/sda-pipeline" | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- run: bash aggregate-repositories.sh ${{ inputs.repository }} | ||
|
||
- name: Create Pull Request | ||
uses: peter-evans/create-pull-request@v4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"neicnordic/sda-pipeline": { | ||
"cmd/backup/backup.md": "docs/services/backup.md", | ||
"cmd/finalize/finalize.md": "docs/services/finalize.md", | ||
"cmd/ingest/ingest.md": "docs/services/ingest.md", | ||
"cmd/intercept/intercept.md": "docs/services/intercept.md", | ||
"cmd/mapper/mapper.md": "docs/services/mapper.md", | ||
"cmd/notify/notify.md": "docs/services/notify.md", | ||
"cmd/verify/verify.md": "docs/services/verify.md", | ||
"cmd/pipeline.md": "docs/services/pipeline.md" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/bin/bash | ||
# | ||
# This script is run in the "Aggregate documentation" github workflow. | ||
# | ||
# The script takes one or more repositories as arguments, clones those | ||
# repositories main branches, and copies files into this repo according to the | ||
# mappings in `aggregate-mappings.json`. | ||
# | ||
|
||
set -e | ||
|
||
echo "Aggregating files" | ||
|
||
for repo in "$@" | ||
do | ||
# clone repo into a temp dir | ||
tempdir="$(mktemp -d)" | ||
git clone "https://github.com/$repo" "$tempdir/${repo#*/}" | ||
|
||
# get file mappings from mappings file | ||
repo_mappings=$(jq .["\"$repo\""] < aggregate-mappings.json) | ||
for key in $(jq -r 'keys[]' <<< "$repo_mappings") | ||
do | ||
target=$(jq -r .["\"$key\""] <<< "$repo_mappings") | ||
if [ -f "$tempdir/${repo#*/}/$key" ] | ||
then | ||
cp "$tempdir/${repo#*/}/$key" "$target" | ||
git add "$target" | ||
fi | ||
done | ||
|
||
# check if there are any changes | ||
if ! git status | grep 'nothing to commit' | ||
then | ||
# commit files to repo | ||
msg=$(date +"Update from $repo at %H:%M on %Y-%m-%d") | ||
|
||
git config --global user.name 'Github aggregate action' | ||
git config --global user.email 'aggregate@users.noreply.github.com' | ||
git commit -m "$msg" | ||
else | ||
echo "No changes to commit" | ||
fi | ||
|
||
# clean up temp dir | ||
rm -rf "$tempdir" | ||
|
||
done |