Skip to content

automating maintenance with Github actions #290

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jan 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/workflows/maintenance.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
on:
push:
branches: [ master ]
schedule:
- cron: '*/5 * * * *'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems aggressive to run every 5 minutes. I thought it was enough to run it daily. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

usually unsubscribe from notifications from the generated PRs

workflow_dispatch: # Enables on-demand/manual triggering
jobs:
job:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: true
- uses: actions/setup-go@v2
with:
go-version: 1.17
- run: |
go get github.com/aws/aws-sdk-go
go mod tidy
go generate ./...
cd tools/provider-schema
terraform init -upgrade
terraform providers schema -json > schema.json
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I'm surprised that ubuntu-latest includes Terraform by default.
https://github.com/actions/virtual-environments/blob/cd453927cac82e4dc2658bb65d42b2c97eb83212/images/linux/scripts/installers/terraform.sh

However, this action may fail when a new version is released. It seems good to pin the version using setup-terraform.
https://github.com/hashicorp/setup-terraform

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the pointer, considered installing tfenv as recommended in our docs but knew there were issues installing it when terraform was already installed. I'll look into that instead

- uses: peter-evans/create-pull-request@v3
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When this pull request is created, it will not trigger workflows, since GH Actions forbids recursion when using secrets.GITHUB_TOKEN.

Copy link
Contributor Author

@PatMyron PatMyron Jan 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not elegant, but I usually just close/re-open the PRs to manually kick off the tests:
peter-evans/create-pull-request#48

added to the body of the generated PRs in case we ever need a reminder about that workaround

with:
commit-message: |
autogenerated maintenance
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
autogenerated maintenance
Generate rules from terraform-provider-aws. Automatically generated via the [maintenance](.github/workflows/maintenance.yaml) workflow.

title: autogenerated maintenance
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
title: autogenerated maintenance
title: Generate rules from terraform-provider-aws

Would be nice to append @version as well, but that may increase the difficulty of targeting the PR. Dependabot/Renovate do something like this but probably w/ considerable logic involved.

Copy link
Contributor Author

@PatMyron PatMyron Jan 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also not elegant, but I've just manually appended version numbers to autogenerated PR titles in the past due to complexities of appending it automatically:
aws-cloudformation/cfn-lint-visual-studio-code#76

delete-branch: true
body: |
If tests are stuck on https://github.com/peter-evans/create-pull-request/issues/48:
["Manually close pull requests and immediately reopen them. This will enable `on: pull_request` workflows to run and be added as checks."](https://github.com/peter-evans/create-pull-request/blob/master/docs/concepts-guidelines.md#triggering-further-workflow-runs)
9 changes: 4 additions & 5 deletions tools/provider-schema/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ This `schema.json` file is used to get information against the terraform-provide

## Update schema file

```console
$ tfenv install
# Edit provider.tf to update provider version
$ terraform init -upgrade
$ terraform providers schema -json > schema.json
```sh
tfenv install
terraform init -upgrade
terraform providers schema -json > schema.json
```
1 change: 0 additions & 1 deletion tools/provider-schema/provider.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "3.70.0"
}
}
}