Skip to content

Commit d92ddf9

Browse files
authored
Merge pull request #147 from kartverket/feature/generic-workflow-for-docs
Feature/generic workflow for docs
2 parents 74a2d22 + 5b9eed4 commit d92ddf9

2 files changed

Lines changed: 132 additions & 1 deletion

File tree

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: Create a pull request to update documentation on skip.kartverket.no
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
source_path:
7+
type: string
8+
required: true
9+
description: "Path to the source file to copy"
10+
target_path:
11+
type: string
12+
required: true
13+
description: "Path to the target file to copy to"
14+
branch_name:
15+
type: string
16+
required: false
17+
default: "update-docs-branch"
18+
description: "Branch name for the PR"
19+
author_name:
20+
type: string
21+
required: false
22+
default: "GithubActions <workflow@kartverket.no>"
23+
identity:
24+
type: string
25+
required: true
26+
description: "The OIDC identity to use for authentication"
27+
28+
jobs:
29+
sync-docs:
30+
name: Update target repository
31+
permissions:
32+
contents: write
33+
id-token: write
34+
35+
runs-on: ubuntu-latest
36+
steps:
37+
- uses: octo-sts/action@6177b4481c00308b3839969c3eca88c96a91775f # v1.0.0 from https://skip.kartverket.no/docs/applikasjon-utrulling/argo-cd/hva-er-et-apps-repo
38+
id: octo-sts
39+
with:
40+
scope: kartverket/skip.kartverket.no
41+
identity: ${{ inputs.identity }}
42+
43+
- name: Checkout source repo
44+
uses: actions/checkout@v5
45+
with:
46+
path: source
47+
persist-credentials: false
48+
49+
- name: Checkout target repo
50+
uses: actions/checkout@v5
51+
with:
52+
path: target
53+
repository: kartverket/skip.kartverket.no
54+
token: ${{steps.octo-sts.outputs.token}}
55+
persist-credentials: false
56+
57+
- name: Copy source file to target
58+
run: |
59+
cp source/${SOURCE_PATH} target/${TARGET_PATH}
60+
env:
61+
SOURCE_PATH: ${{ inputs.source_path }}
62+
TARGET_PATH: ${{ inputs.target_path }}
63+
64+
- name: Create PR
65+
uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e
66+
with:
67+
path: target
68+
token: ${{ steps.octo-sts.outputs.token }}
69+
branch: ${{ inputs.branch_name }}
70+
commit-message: "Update documentation"
71+
title: "Update documentation"
72+
body: "Automated update of documentation"
73+
labels: documentation
74+
author: ${{ inputs.author_name }}

README.md

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Shared reusable workflows for GitHub Actions.
77
- [run-k8s-manifests-validate](#run-k8s-manifests-validate)
88
- [manifest-diff-to-pr-comment](#manifest-diff-to-pr-comment)
99
- [auto-merge-dependabot](#auto-merge-dependabot)
10+
- [update-skip-docs](#update-skip-docs)
1011
- [run-terraform](#run-terraform)
1112
- [Example usage](#example-usage)
1213
- [Ideal Use of Reusable Workflows](#ideal-use-of-reusable-workflows)
@@ -24,7 +25,7 @@ Shared reusable workflows for GitHub Actions.
2425

2526
# Reusable Workflows
2627

27-
We currently have 4 reusable workflows (i.e. [run-terraform](#run-terraform)) available for use.
28+
We currently have 6 reusable workflows (i.e. [run-terraform](#run-terraform)) available for use.
2829

2930
See [Ideal Use of Workflows](#ideal-use-of-reusable-workflows) for an example of how to optimally use all 3 workflows together.
3031

@@ -257,6 +258,62 @@ The configfile is currently the only input. The configfile at `.github/auto-merg
257258
| `[].match.update_type` | string | true | Which changes should be merged. Currently supports `semver:patch`, `semver:minor` and `semver:major`. The type includes all lower tiers, for example `semver:minor` includes patch changes |
258259
| `[].match.package_ecosystem` | string | true | The name of the package ecosystem which the update belongs to, examples; terraform, golang |
259260

261+
## update-skip-docs
262+
263+
Automatically creates a pull request for updating documentation on skip.kartverket.no when documentation changes are pushed.
264+
265+
### Features
266+
267+
- Syncs changes to documentation files in the source repository to target in skip.kartverket.no
268+
- Automatically creates or updates documentation in the target repository
269+
- Creates a branch with the changes in the target repository
270+
- Requires manual merge of the created branch/PR to allow for review
271+
272+
### Requirements
273+
274+
- The workflow needs write permissions for both `contents` and `id-token`
275+
- An STS trust file needs to be configured for the target repository
276+
- The specified identity must have access to the target repository
277+
278+
### Example
279+
280+
Example usage in `.github/workflows/update-docs.yml`:
281+
```yaml
282+
name: Update documentation
283+
284+
on:
285+
push:
286+
branches:
287+
- main
288+
paths:
289+
- 'README.md'
290+
291+
permissions:
292+
contents: write
293+
id-token: write
294+
295+
jobs:
296+
update-docs:
297+
name: Update documentation in target repository
298+
uses: kartverket/github-workflows/.github/workflows/update-skip-docs.yaml@latest
299+
with:
300+
source_path: "README.md"
301+
target_path: "docs/03-applikasjon-utrulling/10-argokit/09-argokit-v2.md"
302+
branch_name: "update-argokitv2-docs-branch"
303+
author_name: "GithubActions <argokit@kartverket.no>"
304+
identity: "argokit"
305+
```
306+
307+
### Inputs
308+
309+
| Key | Type | Required | Description |
310+
|---------------|--------|----------|--------------------------------------------------------------------------------------------------|
311+
| `source_path` | string | true | Path to the documentation file in the source repository |
312+
| `target_path` | string | true | Path where the documentation should be placed in the target repository |
313+
| `branch_name` | string | false | Name of the branch to create in the target repository with the documentation updates |
314+
| `author_name` | string | false | Git author name and email in the format "Name <email@domain.com>" for the commit |
315+
| `identity` | string | true | The `identity` to use for authentication with the target repository (must match STS configuration) |
316+
260317
## run-terraform
261318

262319
This workflow plans and applies Terraform config to deploy to an environment.

0 commit comments

Comments
 (0)