-
-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
90 additions
and
62 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
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,41 @@ | ||
#!/bin/bash | ||
|
||
export THIS_UPDATE_SHA= | ||
export LATEST_NULL_LABEL_VERSION= | ||
|
||
export CREATE_PR=false | ||
export CREATE_RELEASE=false | ||
export PR_LABELS=auto-update | ||
|
||
# Use/parse a JSON file to limit damage from malicious content | ||
export CHECKPOINT_FILE=".github/last-update.json" | ||
CHECKPOINT_TEMPLATE='{ "LAST_UPDATE_SHA": "%s", "LAST_NULL_LABEL_VERSION": "%s" }\n' | ||
|
||
function set_outputs() { | ||
printf "::set-output name=create_pull_request::%s\n" "${CREATE_PR}" | ||
[[ "${CREATE_RELEASE}" == "true" ]] || PR_LABELS+=,no-release | ||
printf "::set-output name=pull_request_labels::%s\n" "${PR_LABELS}" | ||
printf "::set-output name=nightly_update_sha::%s\n" "${THIS_UPDATE_SHA}" | ||
printf "::set-output name=null_label_version::%s\n" "${LATEST_NULL_LABEL_VERSION}" | ||
} | ||
|
||
trap set_outputs EXIT RETURN | ||
|
||
if [[ -r $CHECKPOINT_FILE ]]; then | ||
LAST_UPDATE_SHA=$(jq -r .LAST_UPDATE_SHA <x) | ||
if [[ "${LAST_UPDATE_SHA}" == "${THIS_UPDATE_SHA}" ]]; then | ||
printf "Already updated to %s. Exiting.\n" "$LAST_UPDATE_SHA" | ||
exit 0 | ||
fi | ||
else | ||
touch "$CHECKPOINT_FILE" | ||
fi | ||
|
||
if [[ -f context.tf && "${LATEST_NULL_LABEL_VERSION}" != $(terraform-config-inspect --json | jq '.module_calls.this.version') ]]; then | ||
/usr/bin/make BUILD_HARNESS_PATH=/build-harness PACKAGES_PREFER_HOST=true -f /build-harness/templates/Makefile.build-harness github/init/context.tf | ||
CREATE_PR=true | ||
|
||
# TODO update all usages of null label | ||
# for files in in $(terraform-config-inspect --json | jq -cr '.module_calls[] | select(.source == "cloudposse/label/null" and .name != "this") | .pos.filename' | sort | uniq); do | ||
|
||
fi |
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
This file was deleted.
Oops, something went wrong.
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
40 changes: 40 additions & 0 deletions
40
templates/terraform/.github/workflows/nightly-update-terraform.yml
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,40 @@ | ||
name: "nightly" | ||
on: | ||
schedule: | ||
# Update Terraform modules nightly | ||
- cron: '0 3 * * *' | ||
|
||
jobs: | ||
update: | ||
if: github.event_name == 'schedule' | ||
runs-on: ubuntu-latest | ||
container: cloudposse/build-harness:latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Nightly Update | ||
id: nightly | ||
if: github.event_name == 'schedule' | ||
shell: bash | ||
run: /usr/bin/make BUILD_HARNESS_PATH=/build-harness PACKAGES_PREFER_HOST=true -f /build-harness/templates/Makefile.build-harness terraform/nightly/host | ||
|
||
- name: Create Pull Request | ||
if: steps.nightly.outputs.create_pull_request == 'true' | ||
uses: cloudposse/actions/github/[email protected] | ||
with: | ||
token: ${{ secrets.PUBLIC_REPO_ACCESS_TOKEN }} | ||
committer: 'cloudpossebot <[email protected]>' | ||
author: 'cloudpossebot <[email protected]>' | ||
commit-message: Nightly update null ${{ steps.nightly.outputs.null_label_version }}/SHA ${{ steps.nightly.outputs.nightly_update_sha }} | ||
title: Nightly update null ${{ steps.nightly.outputs.null_label_version }}/SHA ${{ steps.nightly.outputs.nightly_update_sha }} | ||
body: |- | ||
## what | ||
This is an auto-generated PR that keeps this module up-to-date | ||
## why | ||
Keep everythign in sync | ||
branch: auto-update/nightly | ||
base: master | ||
delete-branch: true | ||
labels: ${{ steps.nightly.outputs.pull_request_labels }} |