From 4fc1544794bad20d29b2fd9a8222e28d3de5e33d Mon Sep 17 00:00:00 2001 From: "dealroomba-app[bot]" <189869926+dealroomba-app[bot]@users.noreply.github.com> Date: Fri, 13 Dec 2024 12:12:23 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=84=20synced=20file(s)=20with=20dealro?= =?UTF-8?q?om/core-mothership=20(#226)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: dealroomba-app[bot] <189869926+dealroomba-app[bot]@users.noreply.github.com> --- .../scripts/delete-unused-labels/script.sh | 12 +- .github/workflows/autolabel.yml | 3 +- .github/workflows/automerge.yml | 2 +- .github/workflows/lint.yml | 6 + .github/workflows/migrate_20241213.yml | 153 ++++++++++++++++++ prettier.config.cjs | 8 - 6 files changed, 168 insertions(+), 16 deletions(-) create mode 100644 .github/workflows/migrate_20241213.yml diff --git a/.github/scripts/delete-unused-labels/script.sh b/.github/scripts/delete-unused-labels/script.sh index 8c5653f..f65e558 100755 --- a/.github/scripts/delete-unused-labels/script.sh +++ b/.github/scripts/delete-unused-labels/script.sh @@ -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" @@ -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 diff --git a/.github/workflows/autolabel.yml b/.github/workflows/autolabel.yml index f4e93f6..7895592 100644 --- a/.github/workflows/autolabel.yml +++ b/.github/workflows/autolabel.yml @@ -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 @@ -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: diff --git a/.github/workflows/automerge.yml b/.github/workflows/automerge.yml index 2b9741f..15f7190 100644 --- a/.github/workflows/automerge.yml +++ b/.github/workflows/automerge.yml @@ -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() && diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 12e1eea..b05e093 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -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! @@ -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: | @@ -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 @@ -251,3 +256,4 @@ jobs: commit_user_name: dealroomba commit_user_email: dealroomba@users.noreply.github.com commit_author: dealroomba +# jscpd:ignore-end diff --git a/.github/workflows/migrate_20241213.yml b/.github/workflows/migrate_20241213.yml new file mode 100644 index 0000000..9d0baf7 --- /dev/null +++ b/.github/workflows/migrate_20241213.yml @@ -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 "//!b;//!i " + else + find . -type d -name ".terraform" -prune -o -type f -name "README.md" -print0 | \ + xargs -0 sed -i "//!b;//!a " + fi + } + ensure_no_duplicates() { + find . -type d -name ".terraform" -prune -o -type f -name "README.md" -print0 | \ + xargs -0 sed -i '//d; //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 diff --git a/prettier.config.cjs b/prettier.config.cjs index 027c102..6132730 100644 --- a/prettier.config.cjs +++ b/prettier.config.cjs @@ -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' - } } ] }