From 514e788e880f28d6f6918cd6bc50d3db0b83175d Mon Sep 17 00:00:00 2001 From: Semyon Levin <231188+remal@users.noreply.github.com> Date: Thu, 14 Nov 2024 19:17:25 -0800 Subject: [PATCH] Template repository changes: remal-github-actions/template-typescript (#715) Co-authored-by: remal-github-actions <77626445+remal-github-actions+sync-with-template@users.noreply.github.com> --- .../workflows/bump-repository-activity.yml | 27 +++++------------ .github/workflows/check-action-secrets.yml | 30 ++++++------------- .github/workflows/codeowners-validator.yml | 6 ++-- .../rebase-dependabot-pull-requests.yml | 28 +++++------------ .github/workflows/release-drafter.yml | 26 +++++++++++++++- .github/workflows/sync-with-template.yml | 29 +++++------------- 6 files changed, 60 insertions(+), 86 deletions(-) diff --git a/.github/workflows/bump-repository-activity.yml b/.github/workflows/bump-repository-activity.yml index c3a14202..f7ede83a 100644 --- a/.github/workflows/bump-repository-activity.yml +++ b/.github/workflows/bump-repository-activity.yml @@ -14,8 +14,8 @@ env: PUSH_BACK_TOKEN: ${{secrets.PUSH_BACK_TOKEN}} jobs: - rate-limits: - name: Check rate limits + bump-repository-activity: + name: Bump repository activity runs-on: ubuntu-latest timeout-minutes: 5 concurrency: @@ -24,14 +24,14 @@ jobs: steps: - name: Get rate limits uses: remal-github-actions/get-rate-limits@v1 - id: getRateLimits + id: rate-limits with: githubToken: ${{env.PUSH_BACK_TOKEN || github.token}} - - name: Make decision + - name: Make rate limits decision id: decision run: | - echo "Core rate limit usage: ${{steps.getRateLimits.outputs.coreUsage}}" - if [ "${{steps.getRateLimits.outputs.coreUsage < 75}}" == "true" ]; then + echo "Core rate limit usage: ${{steps.rate-limits.outputs.coreUsage}}" + if [ "${{steps.rate-limits.outputs.coreUsage < 75}}" == "true" ]; then echo "Enough rate limits" echo 'enough=true' >> $GITHUB_OUTPUT else @@ -41,22 +41,9 @@ jobs: fi echo 'enough=false' >> $GITHUB_OUTPUT fi - outputs: - enough: ${{steps.decision.outputs.enough}} - bump-repository-activity: - needs: - - rate-limits - if: ${{github.event_name != 'schedule' || fromJSON(needs.rate-limits.outputs.enough) == true}} - name: Bump repository activity - runs-on: ubuntu-latest - timeout-minutes: 5 - concurrency: - group: bump-repository-activity - cancel-in-progress: true - steps: - name: Bump repository activity - if: ${{env.PUSH_BACK_TOKEN}} + if: ${{env.PUSH_BACK_TOKEN && (github.event_name != 'schedule' || fromJSON(steps.decision.outputs.enough) == true)}} uses: remal-github-actions/bump-repository-activity@v1 with: githubToken: ${{env.PUSH_BACK_TOKEN}} diff --git a/.github/workflows/check-action-secrets.yml b/.github/workflows/check-action-secrets.yml index be0420fa..132fc0a8 100644 --- a/.github/workflows/check-action-secrets.yml +++ b/.github/workflows/check-action-secrets.yml @@ -16,24 +16,24 @@ defaults: shell: bash jobs: - rate-limits: - name: Check rate limits + check-action-secrets: + name: Check action secrets runs-on: ubuntu-latest - timeout-minutes: 5 + timeout-minutes: 10 concurrency: group: check-action-secrets cancel-in-progress: true steps: - name: Get rate limits uses: remal-github-actions/get-rate-limits@v1 - id: getRateLimits + id: rate-limits with: - githubToken: ${{secrets.LIST_SECRETS || github.token}} - - name: Make decision + githubToken: ${{env.PUSH_BACK_TOKEN || github.token}} + - name: Make rate limits decision id: decision run: | - echo "Core rate limit usage: ${{steps.getRateLimits.outputs.coreUsage}}" - if [ "${{steps.getRateLimits.outputs.coreUsage < 75}}" == "true" ]; then + echo "Core rate limit usage: ${{steps.rate-limits.outputs.coreUsage}}" + if [ "${{steps.rate-limits.outputs.coreUsage < 75}}" == "true" ]; then echo "Enough rate limits" echo 'enough=true' >> $GITHUB_OUTPUT else @@ -43,21 +43,9 @@ jobs: fi echo 'enough=false' >> $GITHUB_OUTPUT fi - outputs: - enough: ${{steps.decision.outputs.enough}} - check-action-secrets: - needs: - - rate-limits - if: ${{github.event_name != 'schedule' || fromJSON(needs.rate-limits.outputs.enough) == true}} - name: Check action secrets - runs-on: ubuntu-latest - timeout-minutes: 10 - concurrency: - group: check-action-secrets - cancel-in-progress: true - steps: - name: Check action secrets + if: ${{github.event_name != 'schedule' || fromJSON(steps.decision.outputs.enough) == true}} uses: remal-github-actions/check-action-secrets@v1 with: githubToken: ${{secrets.LIST_SECRETS}} diff --git a/.github/workflows/codeowners-validator.yml b/.github/workflows/codeowners-validator.yml index 58242d26..5908e7dd 100644 --- a/.github/workflows/codeowners-validator.yml +++ b/.github/workflows/codeowners-validator.yml @@ -30,14 +30,14 @@ jobs: steps: - name: Get rate limits uses: remal-github-actions/get-rate-limits@v1 - id: getRateLimits + id: rate-limits with: githubToken: ${{env.VALIDATION_TOKEN || github.token}} - name: Make decision id: decision run: | - echo "Core rate limit usage: ${{steps.getRateLimits.outputs.coreUsage}}" - if [ "${{steps.getRateLimits.outputs.coreUsage < 75}}" == "true" ]; then + echo "Core rate limit usage: ${{steps.rate-limits.outputs.coreUsage}}" + if [ "${{steps.rate-limits.outputs.coreUsage < 75}}" == "true" ]; then echo "Enough rate limits" echo 'enough=true' >> $GITHUB_OUTPUT else diff --git a/.github/workflows/rebase-dependabot-pull-requests.yml b/.github/workflows/rebase-dependabot-pull-requests.yml index 71592c0f..7d5740d5 100644 --- a/.github/workflows/rebase-dependabot-pull-requests.yml +++ b/.github/workflows/rebase-dependabot-pull-requests.yml @@ -19,24 +19,24 @@ env: PUSH_BACK_TOKEN: ${{secrets.PUSH_BACK_TOKEN || github.token}} jobs: - rate-limits: - name: Check rate limits + rebase-dependabot-pull-requests: + name: Rebase Dependabot pull requests runs-on: ubuntu-latest - timeout-minutes: 5 + timeout-minutes: 15 concurrency: group: rebase-dependabot-pull-requests cancel-in-progress: true steps: - name: Get rate limits uses: remal-github-actions/get-rate-limits@v1 - id: getRateLimits + id: rate-limits with: githubToken: ${{env.PUSH_BACK_TOKEN || github.token}} - - name: Make decision + - name: Make rate limits decision id: decision run: | - echo "Core rate limit usage: ${{steps.getRateLimits.outputs.coreUsage}}" - if [ "${{steps.getRateLimits.outputs.coreUsage < 75}}" == "true" ]; then + echo "Core rate limit usage: ${{steps.rate-limits.outputs.coreUsage}}" + if [ "${{steps.rate-limits.outputs.coreUsage < 75}}" == "true" ]; then echo "Enough rate limits" echo 'enough=true' >> $GITHUB_OUTPUT else @@ -46,21 +46,9 @@ jobs: fi echo 'enough=false' >> $GITHUB_OUTPUT fi - outputs: - enough: ${{steps.decision.outputs.enough}} - rebase-dependabot-pull-requests: - needs: - - rate-limits - if: ${{github.event_name != 'schedule' || fromJSON(needs.rate-limits.outputs.enough) == true}} - name: Rebase Dependabot pull requests - runs-on: ubuntu-latest - timeout-minutes: 15 - concurrency: - group: rebase-dependabot-pull-requests - cancel-in-progress: true - steps: - name: Rebase Dependabot pull requests + if: ${{github.event_name != 'schedule' || fromJSON(steps.decision.outputs.enough) == true}} uses: remal-github-actions/rebase-dependabot-pull-requests@v1 with: githubToken: ${{env.PUSH_BACK_TOKEN}} diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml index 22da2ed8..d1926d9c 100644 --- a/.github/workflows/release-drafter.yml +++ b/.github/workflows/release-drafter.yml @@ -13,10 +13,34 @@ permissions: pull-requests: write jobs: - update_release_draft: + update-release-draft: name: Update release draft runs-on: ubuntu-latest + concurrency: + group: update-release-draft + cancel-in-progress: true steps: + - uses: actions/github-script@v7 + name: Check if Release Drafter config exists in the repository + id: config + with: + script: | + const configFile = '.github/release-drafter.yml' + const configFileExists = await github.rest.repos.getContent({ + owner: context.repo.owner, + repo: context.repo.repo, + path: configFile, + }).then( + () => true, + error => { if (error.response && error.response.status === 404) return false; else throw error; } + ) + if (!configFileExists) { + core.info("Config file doesn't exist: " + configFile) + } + core.setOutput('exists', configFileExists ? 'true' : 'false') + - uses: release-drafter/release-drafter@v6 + name: Update release draft + if: ${{fromJSON(steps.config.outputs.exists) == true}} env: GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} diff --git a/.github/workflows/sync-with-template.yml b/.github/workflows/sync-with-template.yml index bdbd3556..14e83d39 100644 --- a/.github/workflows/sync-with-template.yml +++ b/.github/workflows/sync-with-template.yml @@ -21,24 +21,24 @@ env: PUSH_BACK_TOKEN: ${{secrets.PUSH_BACK_TOKEN}} jobs: - rate-limits: - name: Check rate limits + sync-with-template: + name: Sync with template repository runs-on: ubuntu-latest - timeout-minutes: 5 + timeout-minutes: 30 concurrency: group: sync-with-template cancel-in-progress: true steps: - name: Get rate limits uses: remal-github-actions/get-rate-limits@v1 - id: getRateLimits + id: rate-limits with: githubToken: ${{env.PUSH_BACK_TOKEN || github.token}} - - name: Make decision + - name: Make rate limits decision id: decision run: | - echo "Core rate limit usage: ${{steps.getRateLimits.outputs.coreUsage}}" - if [ "${{steps.getRateLimits.outputs.coreUsage < 75}}" == "true" ]; then + echo "Core rate limit usage: ${{steps.rate-limits.outputs.coreUsage}}" + if [ "${{steps.rate-limits.outputs.coreUsage < 75}}" == "true" ]; then echo "Enough rate limits" echo 'enough=true' >> $GITHUB_OUTPUT else @@ -48,22 +48,9 @@ jobs: fi echo 'enough=false' >> $GITHUB_OUTPUT fi - outputs: - enough: ${{steps.decision.outputs.enough}} - sync-with-template: - needs: - - rate-limits - if: ${{github.event_name != 'schedule' || fromJSON(needs.rate-limits.outputs.enough) == true}} - name: Sync with template repository - runs-on: ubuntu-latest - timeout-minutes: 30 - concurrency: - group: sync-with-template - cancel-in-progress: true - steps: - name: Sync with template repository - if: ${{env.PUSH_BACK_TOKEN}} + if: ${{env.PUSH_BACK_TOKEN && (github.event_name != 'schedule' || fromJSON(steps.decision.outputs.enough) == true)}} uses: remal-github-actions/sync-with-template@v3 with: githubToken: ${{env.PUSH_BACK_TOKEN}}