Skip to content

Commit

Permalink
Align files (#336)
Browse files Browse the repository at this point in the history
Co-authored-by: github-actions <action@github.com>
Co-authored-by: Christian Bianchi <christian@giantswarm.io>
  • Loading branch information
3 people committed Apr 5, 2023
1 parent 3626535 commit 0e79c87
Show file tree
Hide file tree
Showing 14 changed files with 294 additions and 85 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
version: 2.1

orbs:
architect: giantswarm/architect@4.23.0
architect: giantswarm/architect@4.28.1

workflows:
build:
Expand Down
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 }}
64 changes: 31 additions & 33 deletions .github/workflows/zz_generated.check_values_schema.yaml
Original file line number Diff line number Diff line change
@@ -1,46 +1,44 @@
# DO NOT EDIT. Generated with:
#
# devctl@5.7.0
# devctl@5.21.0
#
name: 'Check if values schema file has been updated'
on: pull_request
name: 'Values and schema'
on:
pull_request:
branches:
- master
- main
paths:
- 'helm/**/values.yaml' # default helm chart values
- 'helm/**/values.schema.json' # schema
- 'helm/**/ci/ci-values.yaml' # overrides for CI (can contain required entries)

jobs:
check:
name: 'Check values.yaml and its schema in PR'
name: 'validate values.yaml against values.schema.json'
runs-on: ubuntu-latest
steps:
- name: 'Checkout'
- name: Checkout
uses: actions/checkout@v3
- name: 'Check if values.schema.json was updated'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
VALUES_FILE_CHANGED="false"
SCHEMA_FILE_CHANGED="false"
echo "Comparing ${GITHUB_BASE_REF}...${GITHUB_HEAD_REF}"
changed_files=$(gh api "repos/{owner}/{repo}/compare/${GITHUB_BASE_REF}...${GITHUB_HEAD_REF}" --jq ".files[] | .filename")
if grep -q "values.schema.json" <<< $(git ls-tree -r --name-only ${GITHUB_SHA}); then
with:
fetch-depth: 0

if grep -q "values.yaml" <<< "${changed_files}" ; then
VALUES_FILE_CHANGED="true"
fi
if grep -q "values.schema.json" <<< "${changed_files}" ; then
SCHEMA_FILE_CHANGED="true"
fi
if [ $VALUES_FILE_CHANGED != $SCHEMA_FILE_CHANGED ]; then
echo "FAILED: values.yaml was updated but values.schema.json hasn't been regenerated"
echo "Please refer to this document: https://intranet.giantswarm.io/docs/organizational-structure/teams/cabbage/app-updates/helm-values-schema/"
exit 1
fi
- name: Install validator
run: |
wget -q -O ${HOME}/yajsv https://github.com/neilpa/yajsv/releases/download/v1.4.1/yajsv.linux.amd64
chmod +x ${HOME}/yajsv
echo "PASSED: values.yaml and values.schema.json both appear to have been updated"
exit 0
- name: 'Check if values.yaml is a valid instance of values.schema.json'
run: |
HELM_DIR=$(git diff --name-only origin/${GITHUB_BASE_REF} ${GITHUB_SHA} \
| grep 'helm/[-a-z].*\/' | head -1 | awk -F '/' '{print $1"/"$2}')
VALUES=${HELM_DIR}/values.yaml
if [ -f ${HELM_DIR}/ci/ci-values.yaml ]; then
# merge ci-values.yaml into values.yaml (providing required values)
echo -e "\nMerged values:\n=============="
yq '. *= load("'${HELM_DIR}'/ci/ci-values.yaml")' ${HELM_DIR}/values.yaml | tee ${HELM_DIR}/combined-values.yaml
echo -e "\n==============\n"
VALUES=${HELM_DIR}/combined-values.yaml
fi
echo "INFO: values.schema.json not present in this repo - nothing to do"
${HOME}/yajsv -s ${HELM_DIR}/values.schema.json ${VALUES}
37 changes: 21 additions & 16 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.7.0
# devctl@5.21.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 All @@ -90,12 +90,12 @@ jobs:
- gather_facts
steps:
- name: Install architect
uses: giantswarm/install-binary-action@v1.0.0
uses: giantswarm/install-binary-action@v1.1.0
with:
binary: "architect"
version: "6.1.0"
version: "6.10.0"
- name: Install semver
uses: giantswarm/install-binary-action@v1.0.0
uses: giantswarm/install-binary-action@v1.1.0
with:
binary: "semver"
version: "3.2.0"
Expand All @@ -114,28 +114,30 @@ 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 "dev@giantswarm.io"
git config --local user.name "taylorbot"
- 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
env:
REMOTE_REPO: "https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git"
REMOTE_REPO: "https://${{ github.actor }}:${{ secrets.TAYLORBOT_GITHUB_ACTION }}@github.com/${{ github.repository }}.git"
branch: "${{ github.ref }}-version-bump"
run: |
git push "${REMOTE_REPO}" HEAD:${{ env.branch }}
- name: Create PR
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
GITHUB_TOKEN: "${{ secrets.TAYLORBOT_GITHUB_ACTION }}"
base: "${{ github.ref }}"
branch: "${{ github.ref }}-version-bump"
version: "${{ needs.gather_facts.outputs.version }}"
Expand Down Expand Up @@ -167,21 +169,24 @@ jobs:
with:
version: ${{ needs.gather_facts.outputs.version }}
path: ./CHANGELOG.md
- name: Set up git identity
run: |
git config --local user.email "dev@giantswarm.io"
git config --local user.name "taylorbot"
- 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:
REMOTE_REPO: "https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git"
REMOTE_REPO: "https://${{ github.actor }}:${{ secrets.TAYLORBOT_GITHUB_ACTION }}@github.com/${{ github.repository }}.git"
run: |
git push "${REMOTE_REPO}" --tags
- name: Create release
id: create_gh_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: "${{ secrets.TAYLORBOT_GITHUB_ACTION }}"
with:
body: ${{ steps.changelog_reader.outputs.changes }}
tag_name: "v${{ needs.gather_facts.outputs.version }}"
Expand All @@ -195,7 +200,7 @@ jobs:
if: ${{ needs.gather_facts.outputs.version }}
steps:
- name: Install semver
uses: giantswarm/install-binary-action@v1.0.0
uses: giantswarm/install-binary-action@v1.1.0
with:
binary: "semver"
version: "3.0.0"
Expand Down

0 comments on commit 0e79c87

Please sign in to comment.