Skip to content

Commit

Permalink
Merge pull request #67 from sprankhub/add-upstream-sync-github-action
Browse files Browse the repository at this point in the history
Add upstream sync GitHub Action
  • Loading branch information
Vinai authored Jul 23, 2023
2 parents 89183b1 + d5b3e55 commit 60aee7b
Showing 1 changed file with 39 additions and 0 deletions.
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,
]
}
}

0 comments on commit 60aee7b

Please sign in to comment.