Skip to content

Commit

Permalink
Align files (#88)
Browse files Browse the repository at this point in the history
Co-authored-by: github-actions <action@github.com>
  • Loading branch information
architectbot and actions-user committed Jan 19, 2023
1 parent 19c12dd commit 1200389
Show file tree
Hide file tree
Showing 8 changed files with 234 additions and 27 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/zz_generated.add-team-labels.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Add appropriate labels to issue

on:
issues:
types: [assigned]

jobs:
build_user_list:
name: Get yaml config of GS users
runs-on: ubuntu-latest
steps:
- name: Get user-mapping
run: |
mkdir -p artifacts
wget --header "Authorization: token ${{ secrets.ISSUE_AUTOMATION }}" \
-O artifacts/users.yaml \
https://raw.githubusercontent.com/giantswarm/github/master/tools/issue-automation/user-mapping.yaml
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: users
path: artifacts/users.yaml
retention-days: 1

add_label:
name: Add team label when assigned
runs-on: ubuntu-latest
needs: build_user_list
steps:
- uses: actions/download-artifact@v3
id: download-users
with:
name: users
- name: Find team label based on user names
run: |
event_assignee=$(cat $GITHUB_EVENT_PATH | jq -r .assignee.login | tr '[:upper:]' '[:lower:]')
echo "Issue assigned to: ${event_assignee}"
TEAMS=$(cat ${{steps.download-users.outputs.download-path}}/users.yaml | tr '[:upper:]' '[:lower:]' | yq ".${event_assignee}.teams" -o csv | tr ',' ' ')
echo "LABEL<<EOF" >> $GITHUB_ENV
for team in ${TEAMS}; do
echo "Team: ${team} | Label: team/${team}"
echo "team/${team}" >> $GITHUB_ENV
done
echo "EOF" >> $GITHUB_ENV
- name: Apply label to issue
if: ${{ env.LABEL != '' }}
uses: actions-ecosystem/action-add-labels@v1
with:
github_token: ${{ secrets.ISSUE_AUTOMATION }}
labels: |
${{ env.LABEL }}
89 changes: 89 additions & 0 deletions .github/workflows/zz_generated.add-to-project-board.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: Add Issue to Project when assigned

on:
issues:
types:
- assigned
- labeled

jobs:
build_user_list:
name: Get yaml config of GS users
runs-on: ubuntu-latest
steps:
- name: Get user-mapping
run: |
mkdir -p artifacts
wget --header "Authorization: token ${{ secrets.ISSUE_AUTOMATION }}" \
-O artifacts/users.yaml \
https://raw.githubusercontent.com/giantswarm/github/master/tools/issue-automation/user-mapping.yaml
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: users
path: artifacts/users.yaml
retention-days: 1
- name: Get label-mapping
run: |
mkdir -p artifacts
wget --header "Authorization: token ${{ secrets.ISSUE_AUTOMATION }}" \
-O artifacts/labels.yaml \
https://raw.githubusercontent.com/giantswarm/github/master/tools/issue-automation/label-mapping.yaml
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: labels
path: artifacts/labels.yaml
retention-days: 1

add_to_personal_board:
name: Add issue to personal board
runs-on: ubuntu-latest
needs: build_user_list
if: github.event.action == 'assigned'
steps:
- uses: actions/download-artifact@v3
id: download-users
with:
name: users
- name: Find personal board based on user names
run: |
event_assignee=$(cat $GITHUB_EVENT_PATH | jq -r .assignee.login | tr '[:upper:]' '[:lower:]')
echo "Issue assigned to: ${event_assignee}"
BOARD=($(cat ${{steps.download-users.outputs.download-path}}/users.yaml | tr '[:upper:]' '[:lower:]' | yq ".${event_assignee}.personalboard"))
echo "Personal board URL: ${BOARD}"
echo "BOARD=${BOARD}" >> $GITHUB_ENV
- name: Add issue to personal board
if: ${{ env.BOARD != 'null' && env.BOARD != '' }}
uses: actions/add-to-project@main
with:
project-url: ${{ env.BOARD }}
github-token: ${{ secrets.ISSUE_AUTOMATION }}

add_to_team_board:
name: Add issue to team board
runs-on: ubuntu-latest
needs: build_user_list
if: github.event.action == 'labeled'
steps:
- uses: actions/download-artifact@v3
id: download-labels
with:
name: labels
- name: Find team board based on label
run: |
event_label=$(cat $GITHUB_EVENT_PATH | jq -r .label.name | tr '[:upper:]' '[:lower:]')
echo "Issue labelled with: ${event_label}"
BOARD=($(cat ${{steps.download-labels.outputs.download-path}}/labels.yaml | tr '[:upper:]' '[:lower:]' | yq ".[\"${event_label}\"].projectboard"))
echo "Team board URL: ${BOARD}"
echo "BOARD=${BOARD}" >> $GITHUB_ENV
- name: Add issue to team board
if: ${{ env.BOARD != 'null' && env.BOARD != '' }}
uses: actions/add-to-project@main
with:
project-url: ${{ env.BOARD }}
github-token: ${{ secrets.ISSUE_AUTOMATION }}
21 changes: 13 additions & 8 deletions .github/workflows/zz_generated.create_release.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# DO NOT EDIT. Generated with:
#
# devctl@5.3.0
# devctl@5.15.0
#
name: Create Release
on:
Expand Down Expand Up @@ -50,7 +50,7 @@ jobs:
fi
version="${version#v}" # Strip "v" prefix.
echo "version=\"${version}\""
echo "::set-output name=version::${version}"
echo "version=${version}" >> $GITHUB_OUTPUT
- name: Checkout code
if: ${{ steps.get_version.outputs.version != '' }}
uses: actions/checkout@v3
Expand All @@ -63,7 +63,7 @@ jobs:
path=''
fi
echo "path=\"$path\""
echo "::set-output name=path::${path}"
echo "path=${path}" >> $GITHUB_OUTPUT
- name: Check if reference version
id: ref_version
run: |
Expand All @@ -81,7 +81,7 @@ jobs:
refversion=true
fi
echo "refversion =\"${refversion}\""
echo "::set-output name=refversion::${refversion}"
echo "refversion=${refversion}" >> $GITHUB_OUTPUT
update_project_go:
name: Update project.go
runs-on: ubuntu-20.04
Expand Down Expand Up @@ -114,17 +114,19 @@ jobs:
version="${{ needs.gather_facts.outputs.version }}"
new_version="$(semver bump patch $version)-dev"
echo "version=\"$version\" new_version=\"$new_version\""
echo "::set-output name=new_version::${new_version}"
echo "new_version=${new_version}" >> $GITHUB_OUTPUT
sed -Ei "s/(version[[:space:]]*=[[:space:]]*)\"${version}\"/\1\"${new_version}\"/" $file
if git diff --exit-code $file ; then
echo "error: no changes in \"$file\"" >&2
exit 1
fi
- name: Set up git identity
run: |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
- name: Commit changes
run: |
file="${{ needs.gather_facts.outputs.project_go_path }}"
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add $file
git commit -m "Bump version to ${{ steps.update_project_go.outputs.new_version }}"
- name: Push changes
Expand Down Expand Up @@ -167,10 +169,13 @@ jobs:
with:
version: ${{ needs.gather_facts.outputs.version }}
path: ./CHANGELOG.md
- name: Set up git identity
run: |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
- name: Create tag
run: |
version="${{ needs.gather_facts.outputs.version }}"
git config --local user.name "github-actions"
git tag "v$version" ${{ github.sha }}
- name: Push tag
env:
Expand Down
90 changes: 74 additions & 16 deletions .github/workflows/zz_generated.create_release_pr.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# DO NOT EDIT. Generated with:
#
# devctl@5.3.0
# devctl@5.15.0
#
name: Create Release PR
on:
Expand Down Expand Up @@ -52,7 +52,7 @@ jobs:
id: gather_facts
run: |
head="${{ inputs.branch || github.event.ref }}"
echo "::set-output name=branch::${head}"
echo "branch=${head}" >> $GITHUB_OUTPUT
head="${head#refs/heads/}" # Strip "refs/heads/" prefix.
if [[ $(echo "$head" | grep -o '#' | wc -l) -gt 1 ]]; then
Expand All @@ -66,7 +66,19 @@ jobs:
version="$(echo $head | awk -F# '{print $NF}')"
if [[ $version =~ ^major|minor|patch$ ]]; then
gh auth login --with-token <<<$(echo -n ${{ secrets.GITHUB_TOKEN }})
version_parts=($(gh api "repos/${{ github.repository }}/releases/latest" --jq '.tag_name[1:] | split(".") | .[0], .[1], .[2]'))
gh_api_get_latest_release_version()
{
if ! version="$(gh api "repos/$1/releases/latest" --jq '.tag_name[1:] | split(".") | .[0], .[1], .[2]')"
then
case "$version" in
*Not\ Found*) echo Assuming v0.0.0, hooray first release! >&2 ; version="0 0 0" ;;
*) version="" ; return 1 ;;
esac
fi
echo "$version"
}
version_parts=($(gh_api_get_latest_release_version "${{ github.repository }}"))
version_major=${version_parts[0]}
version_minor=${version_parts[1]}
version_patch=${version_parts[2]}
Expand All @@ -82,7 +94,7 @@ jobs:
version_major=$((version_major+1))
version_minor=0
version_patch=0
echo "::set-output name=is_major::true"
echo "is_major=true" >> $GITHUB_OUTPUT
;;
*)
echo "Unknown Semver level provided"
Expand All @@ -95,26 +107,28 @@ jobs:
version_major=$(echo "${version}" | cut -d "." -f 1)
version_minor=$(echo "${version}" | cut -d "." -f 2)
version_patch=$(echo "${version}" | cut -d "." -f 3)
if [[ $version_minor = 0 && $version_patch = 0 ]]; then
echo "::set-output name=is_major::true"
# This will help us detect versions with suffixes as majors, i.e 3.0.0-alpha1.
# Even though it's a pre-release, it's still a major.
if [[ $version_minor = 0 && $version_patch =~ ^0.* ]]; then
echo "is_major=true" >> $GITHUB_OUTPUT
fi
fi
repo_name="$(echo '${{ github.repository }}' | awk -F '/' '{print $2}')"
echo "repo_name=\"$repo_name\" base=\"$base\" head=\"$head\" version=\"$version\""
echo "::set-output name=repo_name::${repo_name}"
echo "::set-output name=base::${base}"
echo "::set-output name=head::${head}"
echo "::set-output name=version::${version}"
echo "repo_name=${repo_name}" >> $GITHUB_OUTPUT
echo "base=${base}" >> $GITHUB_OUTPUT
echo "head=${head}" >> $GITHUB_OUTPUT
echo "version=${version}" >> $GITHUB_OUTPUT
- name: Check if PR exists
id: pr_exists
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
run: |
if gh pr view --repo ${{ github.repository }} ${{ steps.gather_facts.outputs.branch }} | grep -i 'state:[[:space:]]*open' >/dev/null; then
gh pr view --repo ${{ github.repository }} ${{ steps.gather_facts.outputs.branch }}
echo "::set-output name=skip::true"
echo "skip=true" >> $GITHUB_OUTPUT
else
echo "::set-output name=skip::false"
echo "skip=false" >> $GITHUB_OUTPUT
fi
create_release_pr:
name: Create release PR
Expand All @@ -140,18 +154,62 @@ jobs:
- name: Prepare release changes
run: |
architect prepare-release ${{ env.architect_flags }} --version "${{ needs.gather_facts.outputs.version }}"
- name: Update version field in Chart.yaml
run: |
# Define chart_dir
repository="${{ needs.gather_facts.outputs.repo_name }}"
chart="helm/${repository}"
# Check chart directory.
if [ ! -d "${chart}" ]
then
echo "Could not find chart directory '${chart}', adding app suffix."
# Add app suffix.
chart="helm/${repository}-app"
# Check chart directory with app suffix.
if [ ! -d "${chart}" ]
then
echo "Could not find chart directory '${chart}', removing app suffix."
# Remove app suffix.
chart="helm/${repository%-app}"
if [ ! -d "${chart}" ]
then
# Print error.
echo "Could not find chart directory '${chart}', doing nothing."
fi
fi
fi
# Define chart YAML.
chart_yaml="${chart}/Chart.yaml"
# Check chart YAML.
if [ -f "${chart_yaml}" ]
then
# check if version in Chart.yaml is templated using architect
if [ $(grep -c "^version:.*\.Version.*$" "${chart_yaml}") = "0" ]; then
yq -i '.version = "${{ needs.gather_facts.outputs.version }}"' "${chart_yaml}"
fi
fi
- name: Bump go module defined in go.mod if needed
run: |
if [ "${{ needs.gather_facts.outputs.is_major }}" = true ] && test -f "go.mod"; then
go install github.com/marwan-at-work/mod/cmd/mod@v0.4.1
go install github.com/marwan-at-work/mod/cmd/mod@v0.4.2
mod upgrade
fi
- name: Set up git identity
run: |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
- name: Create release commit
env:
version: "${{ needs.gather_facts.outputs.version }}"
run: |
git config --local user.email "action@github.com"
git config --local user.name "github-actions"
git add -A
git commit -m "Release v${{ env.version }}"
- name: Push changes
Expand All @@ -165,4 +223,4 @@ jobs:
base: "${{ needs.gather_facts.outputs.base }}"
version: "${{ needs.gather_facts.outputs.version }}"
run: |
hub pull-request -f -m "Release v${{ env.version }}" -a ${{ github.actor }} -b ${{ env.base }} -h ${{ needs.gather_facts.outputs.branch }}
hub pull-request -f -m "Release v${{ env.version }}" -a ${{ github.actor }} -b ${{ env.base }} -h ${{ needs.gather_facts.outputs.branch }}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# DO NOT EDIT. Generated with:
#
# devctl@5.3.0
# devctl@5.15.0
#
name: Ensure major version tags
on:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/zz_generated.gitleaks.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# DO NOT EDIT. Generated with:
#
# devctl@5.3.0
# devctl@5.15.0
#
name: gitleaks

Expand Down
2 changes: 2 additions & 0 deletions .nancy-ignore.generated
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# This file is generated by https://github.com/giantswarm/github
# Repository specific ignores should be added to .nancy-ignore
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# DO NOT EDIT. Generated with:
#
# devctl@5.3.0
# devctl@5.15.0
#

include Makefile.*.mk
Expand Down

0 comments on commit 1200389

Please sign in to comment.