Skip to content
This repository has been archived by the owner on Jan 16, 2025. It is now read-only.

Commit

Permalink
chore: avoid update-docs workflow runs on pushes to main (#3617)
Browse files Browse the repository at this point in the history
Docs should be updated on branches, in case of the locked main branch a
PR is created. This to ensure the main is up-to-date.

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
npalm and github-actions[bot] authored Nov 22, 2023
1 parent 941682e commit 13b1894
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 25 deletions.
29 changes: 8 additions & 21 deletions .github/workflows/update-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,38 +16,25 @@ jobs:
name: Auto update terraform docs
runs-on: ubuntu-latest
steps:
- name: Get installation token
uses: philips-software/app-token-action@a37926571e4cec6f219e06727136efdd073d8657 # ratchet:philips-software/app-token-action@v1.1.2
id: token
with:
app_id: ${{ secrets.FOREST_RELEASER_APP_ID }}
app_base64_private_key: ${{ secrets.FOREST_RELEASER_APP_PRIVATE_KEY_BASE64 }}
auth_type: installation

# We use the app for branches in this this repo to ensure PR chekcs are kept in place.
- if: github.event_name == 'push' && github.repository_owner == 'philips-labs' && github.ref != 'refs/heads/main'
name: Checkout with App Token
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # ratchet:actions/checkout@v4
with:
token: ${{ steps.token.outputs.token }}

- if: (github.event_name == 'push' && github.repository_owner != 'philips-labs') || github.ref == 'refs/heads/main'
name: Checkout with GITHUB Action token
- name: Checkout with GITHUB Action token
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # ratchet:actions/checkout@v4

- name: Generate TF docs
uses: terraform-docs/gh-actions@f6d59f89a280fa0a3febf55ef68f146784b20ba0 # ratchet:terraform-docs/gh-actions@v1.0.0
with:
find-dir: .
git-commit-message: "docs: auto update terraform docs"
git-push: ${{ github.ref != 'refs/heads/main' }}
git-push: ${{ github.ref != 'refs/heads/main' || github.repository_owner != 'philips-labs' }}

# change docs via PR in case of locked main branch
- name: Create Pull Request (main branch only)
if: github.ref == 'refs/heads/main'
if: github.ref == 'refs/heads/main' && github.repository_owner == 'philips-labs'
uses: peter-evans/create-pull-request@153407881ec5c347639a548ade7d8ad1d6740e38 # ratchet:peter-evans/create-pull-request@v5.0.2
with:
token: ${{ steps.token.outputs.token || secrets.GITHUB_TOKEN }}
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "Update Terraform docs"
title: "docs: Update Terraform docs"
branch: ${{ github.event.pull_request.base.ref }}-update-docs
branch: update-docs
branch-suffix: random
base: ${{ github.event.pull_request.base.ref }}
delete-branch: true
2 changes: 1 addition & 1 deletion examples/arm64/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ Be aware some shells will print some end of line character `%`.

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_github_app"></a> [github\_app](#input\_github\_app) | GitHub for API usages. | <pre>object({<br> id = string<br> key_base64 = string<br> })</pre> | n/a | yes |
| <a name="input_github_app"></a> [github\_app](#input\_github\_app) | GitHub App for API usages. | <pre>object({<br> id = string<br> key_base64 = string<br> })</pre> | n/a | yes |

## Outputs

Expand Down
2 changes: 1 addition & 1 deletion examples/arm64/variables.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
variable "github_app" {
description = "GitHub for API usages."
description = "GitHub App for API usages."

type = object({
id = string
Expand Down
2 changes: 1 addition & 1 deletion examples/default/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ terraform output webhook_secret

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_environment"></a> [environment](#input\_environment) | Environment name, used as prefix | `string` | `null` | no |
| <a name="input_environment"></a> [environment](#input\_environment) | Environment name, used as prefix. | `string` | `null` | no |
| <a name="input_github_app"></a> [github\_app](#input\_github\_app) | GitHub for API usages. | <pre>object({<br> id = string<br> key_base64 = string<br> })</pre> | n/a | yes |

## Outputs
Expand Down
2 changes: 1 addition & 1 deletion examples/default/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ variable "github_app" {
}

variable "environment" {
description = "Environment name, used as prefix"
description = "Environment name, used as prefix."

type = string
default = null
Expand Down

0 comments on commit 13b1894

Please sign in to comment.