Skip to content

Commit

Permalink
Merge branch 'get-rid-pat' of github.com:cloudposse/.github into get-…
Browse files Browse the repository at this point in the history
…rid-pat

* 'get-rid-pat' of github.com:cloudposse/.github:
  Added ouputs
  Added outputs
  Updated Migration Scripts (#50)
  Allow release access for tags (#65)
  Added release branches (#59)
  Create auto-release-hotfix.yml (#63)
  `auto-release.yaml` enable  filter-by-commitish (#62)
  Rename auto-release-2.yml to auto-release.yml (#61)
  Rename auto-release.yml to auto-release-2.yml (#60)
  • Loading branch information
goruha committed Apr 10, 2024
2 parents bc9bfdc + 07c6150 commit f55f981
Show file tree
Hide file tree
Showing 45 changed files with 826 additions and 153 deletions.
51 changes: 51 additions & 0 deletions .github/auto-release-hotfix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
filter-by-commitish: true
name-template: 'v$RESOLVED_VERSION'
tag-template: '$RESOLVED_VERSION'
version-template: '$MAJOR.$MINOR.$PATCH'
version-resolver:
major:
labels: []
minor:
labels:
- 'minor'
- 'enhancement'
patch:
labels:
- 'auto-update'
- 'patch'
- 'fix'
- 'bugfix'
- 'bug'
- 'hotfix'
- 'no-release'
default: 'minor'

categories:
- title: '🚀 Enhancements'
labels:
- 'enhancement'
- 'patch'
- title: '🐛 Bug Fixes'
labels:
- 'fix'
- 'bugfix'
- 'bug'
- 'hotfix'
- title: '🤖 Automatic Updates'
labels:
- 'auto-update'

change-template: |
<details>
<summary>$TITLE @$AUTHOR (#$NUMBER)</summary>
$BODY
</details>
template: |
$CHANGES
replacers:
# Remove irrelevant information from Renovate bot
- search: '/(?<=---\s)\s*^#.*(Renovate configuration|Configuration)(?:.|\n)*?This PR has been generated .*/gm'
replace: ''
# Remove Renovate bot banner image
- search: '/\[!\[[^\]]*Renovate\][^\]]*\](\([^)]*\))?\s*\n+/gm'
replace: ''
1 change: 1 addition & 0 deletions .github/auto-release.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
filter-by-commitish: true
name-template: 'v$RESOLVED_VERSION'
tag-template: '$RESOLVED_VERSION'
version-template: '$MAJOR.$MINOR.$PATCH'
Expand Down
2 changes: 2 additions & 0 deletions .github/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ environments:
custom_branches:
- main
- release/**
# - name: "*.*.*"
# type: tag
- name: security
deployment_branch_policy:
custom_branches:
Expand Down
52 changes: 50 additions & 2 deletions .github/workflows/shared-auto-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,60 @@ on:
type: string
required: false
default: '["ubuntu-latest"]'

outputs:
id:
description: The ID of therelease that was created or updated.
value: ${{ jobs.release.outputs.id }}
name:
description: The name of the release
value: ${{ jobs.release.outputs.name }}
tag_name:
description: The name of the tag associated with the release.
value: ${{ jobs.release.outputs.tag_name }}
body:
description: The body of the drafted release.
value: ${{ jobs.release.outputs.body }}
html_url:
description: The URL users can navigate to in order to view the release
value: ${{ jobs.release.outputs.html_url }}
upload_url:
description: The URL for uploading assets to the release, which could be used by GitHub Actions for additional uses, for example the @actions/upload-release-asset GitHub Action.
value: ${{ jobs.release.outputs.upload_url }}
major_version:
description: The next major version number. For example, if the last tag or release was v1.2.3, the value would be v2.0.0.
value: ${{ jobs.release.outputs.major_version }}
minor_version:
description: The next minor version number. For example, if the last tag or release was v1.2.3, the value would be v1.3.0.
value: ${{ jobs.release.outputs.minor_version }}
patch_version:
description: The next patch version number. For example, if the last tag or release was v1.2.3, the value would be v1.2.4.
value: ${{ jobs.release.outputs.patch_version }}
resolved_version:
description: The next resolved version number, based on GitHub labels.
value: ${{ jobs.release.outputs.resolved_version }}
exists:
description: Tag exists so skip new release issue
value: ${{ jobs.check-duplicate.outputs.exists }}

permissions: {}

jobs:
release:
runs-on: ${{ fromJSON(inputs.runs-on) }}
environment: release
outputs:
id: ${{ steps.drafter.outputs.id }}
name: ${{ steps.drafter.outputs.name }}
tag_name: ${{ steps.drafter.outputs.tag_name }}
body: ${{ steps.drafter.outputs.body }}
html_url: ${{ steps.drafter.outputs.html_url }}
upload_url: ${{ steps.drafter.outputs.upload_url }}
major_version: ${{ steps.drafter.outputs.major_version }}
minor_version: ${{ steps.drafter.outputs.minor_version }}
patch_version: ${{ steps.drafter.outputs.patch_version }}
resolved_version: ${{ steps.drafter.outputs.resolved_version }}
exists: ${{ steps.drafter.outputs.exists }}

steps:
- uses: actions/create-github-app-token@v1
id: github-app
Expand All @@ -45,7 +92,8 @@ jobs:
latest: false
# Drafts your next Release notes as Pull Requests are merged into "main"
- uses: cloudposse/github-action-auto-release@v2
- uses: cloudposse/github-action-auto-release@added-outputs
id: drafter
with:
token: ${{ steps.github-app.outputs.token }}
publish: ${{ inputs.publish }}
Expand Down
16 changes: 1 addition & 15 deletions Makefile
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
1 change: 0 additions & 1 deletion migrate/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
deps:
brew install gh yq
pip3 install yamlfix

78 changes: 78 additions & 0 deletions migrate/git-xargs.sh
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}"
107 changes: 0 additions & 107 deletions migrate/lib/badges.sh

This file was deleted.

Loading

0 comments on commit f55f981

Please sign in to comment.