-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* reimplement README.yaml modifications in python * fix dropped comment * log PRs * incremental improvements * refactor to use script instead of git-xargs * update readme * add new migration for github settings
- Loading branch information
Showing
41 changed files
with
722 additions
and
151 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,7 @@ | ||
export DOCKER_ORG ?= cloudposse | ||
export DOCKER_IMAGE ?= $(DOCKER_ORG)/terraform-root-modules | ||
export DOCKER_TAG ?= latest | ||
export DOCKER_IMAGE_NAME ?= $(DOCKER_IMAGE):$(DOCKER_TAG) | ||
export DOCKER_BUILD_FLAGS = | ||
export README_DEPS ?= docs/targets.md docs/terraform.md | ||
export README_DEPS ?= docs/targets.md | ||
-include $(shell curl -sSL -o .build-harness "https://cloudposse.tools/build-harness"; echo .build-harness) | ||
|
||
all: init deps build install run | ||
|
||
deps: | ||
@exit 0 | ||
|
||
build: | ||
@make --no-print-directory docker:build | ||
|
||
push: | ||
docker push $(DOCKER_IMAGE) | ||
|
||
run: | ||
docker run -it ${DOCKER_IMAGE_NAME} sh |
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 |
---|---|---|
@@ -1,4 +1,3 @@ | ||
deps: | ||
brew install gh yq | ||
pip3 install yamlfix | ||
|
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,78 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Due to just endless problems working around `git-xargs` limitations, challenges with rate limits, | ||
# resorting to a basic shell script that does the same thing, but with more control and less magic and no parallelism. | ||
set -e | ||
|
||
migration=$1 | ||
batch=$2 | ||
|
||
# Validate usage | ||
if [[ -z "$migration" || -z "$batch" ]]; then | ||
echo "Usage: $0 <migration_branch> <batch>" | ||
exit 1 | ||
fi | ||
curdir=$(pwd) | ||
migration_branch="migration/${migration}" | ||
migration_dir="migrations/${migration}" | ||
repos="${migration_dir}/${batch}" | ||
|
||
# Test if the repo file exists | ||
if [[ ! -f "$repos" ]]; then | ||
echo "Repo file for ${batch} batch does not exist: $repos" | ||
exit 1 | ||
fi | ||
|
||
if [[ ! -d "migrations/${migration}" ]]; then | ||
echo "Migration does not exist: $migration" | ||
exit 1 | ||
fi | ||
|
||
while IFS= read -r repo; do | ||
if [[ $repo == \#* ]]; then | ||
continue | ||
fi | ||
cd "${curdir}" | ||
repo_name=$(basename "$repo" .git) | ||
repo_owner=$(basename "$(dirname "$repo")") | ||
repo_url="[email protected]:${repo_owner}/${repo_name}.git" | ||
tmp_dir="tmp/$repo_owner/$repo_name" | ||
|
||
echo "Processing $repo_url" | ||
if [[ ! -d "$tmp_dir" ]]; then | ||
mkdir -p $(dirname "$tmp_dir") | ||
git clone "$repo_url" "${tmp_dir}" | ||
fi | ||
|
||
cd "${tmp_dir}" || exit | ||
|
||
# Identify the default branch | ||
default_branch=$(git remote show origin | grep 'HEAD branch' | cut -d' ' -f5) | ||
|
||
git checkout "${default_branch}" | ||
# Ensure our branch is reset to match the remote default branch, so that we can apply the migration cleanly | ||
git reset --hard origin/${default_branch} | ||
git pull origin "${default_branch}" | ||
|
||
if git rev-parse --verify "${migration_branch}" >/dev/null 2>&1; then | ||
echo "Deleting existing ${migration_branch} branch" | ||
git branch -D "${migration_branch}" | ||
fi | ||
echo "Creating ${migration_branch} branch" | ||
git checkout -b "${migration_branch}" | ||
|
||
# Always start clean | ||
git clean -fxd | ||
|
||
export XARGS_DRY_RUN=${XARGS_DRY_RUN:-true} | ||
export XARGS_REPO_NAME="${repo_name}" | ||
export XARGS_REPO_OWNER="${repo_owner}" | ||
export MIGRATE_PATH="${curdir}" | ||
echo "Performing migration..." | ||
$curdir/run.sh "${migration}" | ||
if [[ $? -ne 0 ]]; then | ||
echo "Migration failed for ${repo}" | ||
exit 1 | ||
fi | ||
|
||
done < "${repos}" |
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
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,5 @@ | ||
|
||
function delete_branch_protection() { | ||
local default_branch=$(git remote show origin | grep 'HEAD branch' | cut -d' ' -f5) | ||
gh api -X DELETE /repos/${XARGS_REPO_OWNER}/${XARGS_REPO_NAME}/branches/${default_branch}/protection | ||
} |
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
Oops, something went wrong.