Skip to content

Commit

Permalink
🔄 synced file(s) with dealroom/core-mothership (#226)
Browse files Browse the repository at this point in the history
Co-authored-by: dealroomba-app[bot] <189869926+dealroomba-app[bot]@users.noreply.github.com>
  • Loading branch information
dealroomba-app[bot] authored Dec 13, 2024
1 parent 26cedb0 commit 4fc1544
Show file tree
Hide file tree
Showing 6 changed files with 168 additions and 16 deletions.
12 changes: 6 additions & 6 deletions .github/scripts/delete-unused-labels/script.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#!/bin/bash

LABELS=$(gh label list -R "$REPO_NAME" --json name --jq '.[].name')
echo "Existing labels: $LABELS"
WANT_LABELS=(
EXISTING_LABELS=$(gh label list -R "$REPO_NAME" --json name --jq '.[].name')
echo "Existing labels: $EXISTING_LABELS"

KEEP_LABELS=(
"update-major"
"update-minor"
"update-patch"
"update-digest"
"dependencies"
"force-lint"
"low-risk"
"sync"
"force-lint"
Expand All @@ -17,10 +17,10 @@ WANT_LABELS=(
"stale"
"pre-release"
)
IFS=$'\n' read -r -d '' -a label_array <<<"$LABELS"
IFS=$'\n' read -r -d '' -a label_array <<<"$EXISTING_LABELS"
for label in "${label_array[@]}"; do
echo "Checking label: \"$label\""
if [[ ! "${WANT_LABELS[*]}" =~ $label ]]; then
if [[ ! "${KEEP_LABELS[*]}" =~ $label ]]; then
echo "!!! Deleting label: \"$label\""
gh label delete "$label" -R "$REPO_NAME" --yes || true
fi
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/autolabel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ permissions: read-all
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
dependabot-auto-label:
runs-on: ubuntu-24.04
Expand Down Expand Up @@ -53,7 +54,7 @@ jobs:
# Indirect updates are those that are not direct dependencies of the project
# For example security updates in transitive dependencies
- name: Add a low-risk label for indirect updates
if: steps.dependabot-metadata.outputs.update-type == 'indirect'
if: steps.dependabot-metadata.outputs.dependency-type == 'indirect'
run: |
gh pr edit "$PR_URL" --add-label "low-risk"
env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/automerge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
# To auto-approve the PR, we need to write to the PR
pull-requests: write
repository-projects: write
## NOTICE: "dealroomba" user is deprecated and will be replaced by "dealroomba-app[bot]"
## @deprecated "dealroomba" user is getting removed and will be replaced by "dealroomba-app[bot]"
if: |
!failure()
&&
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# jscpd:ignore-start
# Auto-synced file, managed by [dealroom/core-mothership](https://github.com/dealroom/core-mothership)
# The changes to this file will be automatically overwritten on the next sync. Do not edit by hand!

Expand Down Expand Up @@ -147,6 +148,8 @@ jobs:
github-token: ${{ steps.get_workflow_token.outputs.token }}
extensions: ${{ vars.EXTENSIONS || 'none' }}
env:
# Workaround to silence the warning "Unexpected input 'docs-generate', valid inputs are ..."
# @see https://github.com/octokit/request-action/issues/26#issuecomment-996992989
INPUT_DOCS-GENERATE: false
- name: Add ignores to .prettierignore file
run: |
Expand Down Expand Up @@ -203,7 +206,9 @@ jobs:
VALIDATE_PHP_PHPSTAN: ${{ vars.LINT_VALIDATE_PHPSTAN || null }}
# Do not write summary as we do not need it here
ENABLE_GITHUB_ACTIONS_STEP_SUMMARY: false
#
# Fix mode configuration for specific linters
#
FIX_CSS_PRETTIER: true
FIX_CSS: true
FIX_YAML_PRETTIER: true
Expand Down Expand Up @@ -251,3 +256,4 @@ jobs:
commit_user_name: dealroomba
commit_user_email: [email protected]
commit_author: dealroomba <[email protected]>
# jscpd:ignore-end
153 changes: 153 additions & 0 deletions .github/workflows/migrate_20241213.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
# jscpd:ignore-start
# Auto-synced file, managed by [dealroom/core-mothership](https://github.com/dealroom/core-mothership)
# The changes to this file will be automatically overwritten on the next sync. Do not edit by hand!

name: Migrate (13 December 2024)

on:
push:
branches:
- main

permissions: read-all

jobs:
# WARNING: The following job will be executed exactly 1 time (per repository).
# The workflow is automatically disabled in the last step.
# This as a sort-of global "migration" script for repositories.
migrate:
runs-on: ubuntu-24.04
permissions:
# To be able to sync GHA files
actions: write
# To read the repository contents
contents: read
steps:
- name: Checkout Repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
- name: Delete unnecessary files and folders
run: |
rm -f ./.github/workflows/migrate_20240320.yml
rm -f ./.github/workflows/migrate_20240412.yml
rm -f ./.github/workflows/migrate_20240620.yml
rm -f ./.github/workflows/migrate_20241204.yml
rm -f ./.github/workflows/migrate_20241209.yml
- name: Create needed labels
run: |
#
# Step 1: Recreate labels with improved descriptions
#
gh label create update-major --force -R "$REPO_NAME" --color B60205 --description "Major version dependency updates"
gh label create update-minor --force -R "$REPO_NAME" --color FFA96A --description "Minor version dependency updates"
gh label create update-patch --force -R "$REPO_NAME" --color BDECB6 --description "Patch version dependency updates"
gh label create update-digest --force -R "$REPO_NAME" --color EDEDED --description "Pinning a digest to a dependency"
gh label create dependencies --force -R "$REPO_NAME" --color 1A9035 --description "Dependency updates"
gh label create force-lint --force -R "$REPO_NAME" --color EA8F33 --description "Force linter checks on PR regardless of other labels"
gh label create low-risk --force -R "$REPO_NAME" --color 6E5494 --description "Update which is considered a low risk"
gh label create sync --force -R "$REPO_NAME" --color EAD433 --description "Synchronization process"
gh label create auto-docs --force -R "$REPO_NAME" --color 06A14E --description "Automatically generated documentation"
gh label create do-not-merge --force -R "$REPO_NAME" --color CC3300 --description "Do not merge this PR"
gh label create stale --force -R "$REPO_NAME" --color CD29A1 --description "Stale PR or issue"
gh label create pre-release --force -R "$REPO_NAME" --color 5319E7 --description "Marks a PR as a release preview"
#
# Step 2: Delete all unused labels
#
# Note: This script cannot be inlined due to usage of IFS breaking the GHA ("Error: Process completed with exit code 1.")
#
chmod +x ./.github/scripts/delete-unused-labels/script.sh
./.github/scripts/delete-unused-labels/script.sh
env:
GH_TOKEN: ${{ secrets.GH_TOKEN_DEALROOMBA }}
REPO_NAME: ${{ github.repository }}
- name: Add ignores to .gitignore file
run: |
if [ -f .gitignore ]; then
if ! grep -q "super-linter-output" .gitignore; then
echo "super-linter-output" >> .gitignore
fi
if ! grep -q "super-linter.log" .gitignore; then
echo "super-linter.log" >> .gitignore
fi
if ! grep -q "github_conf" .gitignore; then
echo "github_conf" >> .gitignore
fi
if ! grep -q "gha-creds-*.json" .gitignore; then
echo "gha-creds-*.json" >> .gitignore
fi
if ! grep -q "key.json" .gitignore; then
echo "*key.json" >> .gitignore
fi
else
{
echo "super-linter-output"
echo "super-linter.log"
echo "github_conf"
echo "gha-creds-*.json"
echo "*key.json"
} >> .gitignore
fi
- name: Add ignores to .prettierignore file
run: |
if [ -d ./charts ]; then
if [ -f .prettierignore ]; then
if ! grep -q "charts/" .prettierignore; then
echo "charts/${REPO_NAME}/templates/**/*.yaml" >> .prettierignore
echo "charts/${REPO_NAME}/values/**/*.yaml" >> .prettierignore
fi
else
echo "charts/${REPO_NAME}/templates/**/*.yaml" > .prettierignore
echo "charts/${REPO_NAME}/values/**/*.yaml" >> .prettierignore
fi
fi
if [ -f helmfile.yaml ]; then
if [ -f .prettierignore ]; then
if ! grep -q "helmfile.yaml" .prettierignore; then
echo "helmfile.yaml" >> .prettierignore
fi
else
echo "helmfile.yaml" > .prettierignore
fi
fi
env:
REPO_NAME: ${{ github.event.repository.name }}
- name: Add Prettier Ignore Comments
run: |
add_prettier_ignore() {
local marker="$1"
local comment="$2"
if [ "$comment" == "prettier-ignore-start" ]; then
find . -type d -name ".terraform" -prune -o -type f -name "README.md" -print0 | \
xargs -0 sed -i "/<!-- ${marker} -->/!b;/<!-- ${comment} -->/!i <!-- ${comment} -->"
else
find . -type d -name ".terraform" -prune -o -type f -name "README.md" -print0 | \
xargs -0 sed -i "/<!-- ${marker} -->/!b;/<!-- ${comment} -->/!a <!-- ${comment} -->"
fi
}
ensure_no_duplicates() {
find . -type d -name ".terraform" -prune -o -type f -name "README.md" -print0 | \
xargs -0 sed -i '/<!-- prettier-ignore-start -->/d; /<!-- prettier-ignore-end -->/d'
}
ensure_no_duplicates
add_prettier_ignore "BEGIN_TF_DOCS" "prettier-ignore-start"
add_prettier_ignore "END_TF_DOCS" "prettier-ignore-end"
- name: Create Migration PR
uses: peter-evans/create-pull-request@5e914681df9dc83aa4e4905692ca88beb2f9e91f # v7.0.5
with:
commit-message: "DEV: Repository migration"
title: "DEV: Workflow repository migration"
body: |
:robot: This is an auto-generated PR to migrate the repository.
token: ${{ secrets.GH_TOKEN_DEALROOMBA }}
branch: feature/DEV/repository-migration
delete-branch: true
labels: |
sync
force-lint
- name: Disable itself
run: |
gh workflow disable -R "$GITHUB_REPOSITORY" "${{ github.workflow }}"
env:
GH_TOKEN: ${{ github.token }}
# jscpd:ignore-end
8 changes: 0 additions & 8 deletions prettier.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,6 @@ module.exports = {
options: {
proseWrap: 'preserve'
}
},
{
files: ['**/*.yml', '**/*.yaml'],
options: {
// This doesn't work with the current version of prettier
// @see: https://github.com/prettier/prettier/issues/16037
quoteProps: 'as-needed'
}
}
]
}

0 comments on commit 4fc1544

Please sign in to comment.