Skip to content
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

Add upstream sync GitHub Action #67

Merged
merged 2 commits into from
Jul 23, 2023
Merged
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
39 changes: 39 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -178,3 +178,42 @@ resource "github_repository_file" "codeowners" {
]
}
}

resource "github_repository_file" "merge-upstream-changes" {
for_each = {
for key, value in var.repositories : key => value
if startswith(key, "mageos-") && contains(keys(github_repository.mirrors), replace(key, "mageos-", "mirror-"))
}
repository = github_repository.repositories[each.key].name
branch = github_repository.repositories[each.key].default_branch
file = ".github/workflows/merge-upstream-changes.yml"
content = <<-EOT
on:
schedule:
- cron: "10 10 * * *" # This gives mirror sync, which runs at 9:57, some time to complete.
workflow_dispatch: {}
permissions:
contents: write
pull-requests: write
jobs:
merge-from-mirror:
uses: mage-os/infrastructure/.github/workflows/merge-upstream-changes.yml@main
with:
upstream: ${github_repository.mirrors[replace(each.key, "mageos-", "mirror-")].http_clone_url}
matrix: '{ branch: ["${github_repository.mirrors[replace(each.key, "mageos-", "mirror-")].default_branch}"] }'
secrets:
DISCORD_WEBHOOK: $${{ secrets.DISCORD_WEBHOOK }}
MAGEOS_GITHUB_TOKEN: $${{ secrets.MAGE_OS_CI_TOKEN }}
EOT
commit_message = "Managed by Terraform"
commit_author = "mage-os-ci"
commit_email = "[email protected]"
overwrite_on_create = true

lifecycle {
ignore_changes = [
commit_author,
commit_email,
]
}
}