From aa9fdc55ab2262e0033a678e7173851a27f3710b Mon Sep 17 00:00:00 2001 From: Mircea-Pavel ANTON Date: Fri, 6 Sep 2024 17:48:51 +0000 Subject: [PATCH] update reusable workflows --- .github/workflows/git-release.yaml | 52 ++++++++++-------------- .github/workflows/go-lint.yaml | 22 +++++++++++ .github/workflows/go-release.yaml | 29 ++++++++++++++ .github/workflows/golangci-lint.yaml | 41 ------------------- .github/workflows/goreleaser.yaml | 55 -------------------------- .github/workflows/meta-label-sync.yaml | 39 ++++-------------- .github/workflows/meta-labeler.yaml | 41 +++---------------- .github/workflows/renovate.yaml | 39 ++++-------------- 8 files changed, 91 insertions(+), 227 deletions(-) create mode 100644 .github/workflows/go-lint.yaml create mode 100644 .github/workflows/go-release.yaml delete mode 100644 .github/workflows/golangci-lint.yaml delete mode 100644 .github/workflows/goreleaser.yaml diff --git a/.github/workflows/git-release.yaml b/.github/workflows/git-release.yaml index d0f3423..1245dba 100644 --- a/.github/workflows/git-release.yaml +++ b/.github/workflows/git-release.yaml @@ -3,7 +3,22 @@ name: Git Release on: - workflow_dispatch: {} + workflow_dispatch: + inputs: + dry-run: + description: "Dry run" + required: false + default: false + type: boolean + + pull_request: + paths: + - ".github/workflows/git-release.yaml" + - "cmd/**" + - "go.mod" + - "go.sum" + - "main.go" + push: branches: ["main"] paths: @@ -14,34 +29,7 @@ on: jobs: release: - runs-on: ubuntu-latest - steps: - - name: Generate Token - uses: actions/create-github-app-token@3378cda945da322a8db4b193e19d46352ebe2de5 # v1.10.4 - id: app-token - with: - app-id: "${{ secrets.BOT_APP_ID }}" - private-key: "${{ secrets.BOT_APP_PRIVATE_KEY }}" - - - name: Checkout - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - with: - token: "${{ steps.app-token.outputs.token }}" - - - name: Set up Node.js - uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4 - with: - node-version: "22" - - - name: Install dependencies - run: npm install semantic-release @semantic-release/github - - - name: Run semantic-release - run: | - npx semantic-release \ - --branches=main \ - --plugins=@semantic-release/commit-analyzer \ - --plugins=@semantic-release/release-notes-generator \ - --plugins=@semantic-release/github - env: - GITHUB_TOKEN: "${{ steps.app-token.outputs.token }}" + uses: mirceanton/reusable-workflows/.github/workflows/git-release-semver.yaml@main@779974ececd8243d133c1813f429e3415712456b + secrets: inherit + with: + dry-run: ${{ github.event.inputs.dry-run || github.event.name == 'pull_request' }} diff --git a/.github/workflows/go-lint.yaml b/.github/workflows/go-lint.yaml new file mode 100644 index 0000000..71bc97c --- /dev/null +++ b/.github/workflows/go-lint.yaml @@ -0,0 +1,22 @@ +--- +# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json +name: Go Lint + +on: + workflow_dispatch: {} + + pull_request: + paths: + - ".github/workflows/go-lint.yaml" + - ".golangci.yaml" + - "go.mod" + - "go.sum" + - "cmd/**" + +jobs: + golangci-lint: + uses: mirceanton/reusable-workflows/.github/workflows/go-lint.yaml@main@779974ececd8243d133c1813f429e3415712456b + secrets: inherit + with: + go-version: "1.22.5" + golangci-version: "v1.60.3" diff --git a/.github/workflows/go-release.yaml b/.github/workflows/go-release.yaml new file mode 100644 index 0000000..c39d22e --- /dev/null +++ b/.github/workflows/go-release.yaml @@ -0,0 +1,29 @@ +--- +# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json +name: Go Release + +on: + workflow_dispatch: {} + + push: + tags: ["*"] + + pull_request: + paths: + - ".github/workflows/go-release.yaml" + - ".goreleaser.yaml" + - "go.mod" + - "go.sum" + - "cmd/**" + +jobs: + goreleaser: + uses: mirceanton/reusable-workflows/.github/workflows/go-release.yaml@main@779974ececd8243d133c1813f429e3415712456b + secrets: inherit + with: + go-version: "1.22.5" + goreleaser-version: "v2.2.0" + dry-run: ${{ github.event.inputs.dry-run || github.event_name == 'pull_request' }} + registry-url: "ghcr.io" + registry-username: ${{ github.actor }} + registry-password: ${{ secrets.GHCR_RW_TOKEN }} diff --git a/.github/workflows/golangci-lint.yaml b/.github/workflows/golangci-lint.yaml deleted file mode 100644 index cf61871..0000000 --- a/.github/workflows/golangci-lint.yaml +++ /dev/null @@ -1,41 +0,0 @@ ---- -# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json -name: GolangCI Lint - -on: - workflow_dispatch: {} - push: - tags: ["*"] - pull_request: - paths: - - ".github/workflows/golangci-lint.yaml" - - ".golangci.yaml" - - "go.mod" - - "go.sum" - - "cmd/**" - -jobs: - lint: - runs-on: ubuntu-latest - steps: - - name: Generate Token - uses: actions/create-github-app-token@3378cda945da322a8db4b193e19d46352ebe2de5 # v1.10.4 - id: app-token - with: - app-id: "${{ secrets.BOT_APP_ID }}" - private-key: "${{ secrets.BOT_APP_PRIVATE_KEY }}" - - - name: Checkout - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - with: - token: "${{ steps.app-token.outputs.token }}" - - - name: Set up Go - uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 - with: - go-version: "1.22.x" - - - name: Run lint - uses: golangci/golangci-lint-action@aaa42aa0628b4ae2578232a66b541047968fac86 # v6.1.0 - with: - args: --timeout 3m0s diff --git a/.github/workflows/goreleaser.yaml b/.github/workflows/goreleaser.yaml deleted file mode 100644 index 243e514..0000000 --- a/.github/workflows/goreleaser.yaml +++ /dev/null @@ -1,55 +0,0 @@ ---- -# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json -name: Goreleaser - -on: - workflow_dispatch: {} - push: - tags: ["*"] - pull_request: - paths: - - ".github/workflows/goreleaser.yaml" - - ".goreleaser.yaml" - - "go.mod" - - "go.sum" - - "cmd/**" - -env: - DRY_RUN: ${{ github.event_name == 'workflow_dispatch' || github.event_name == 'pull_request' }} - -jobs: - goreleaser: - runs-on: ubuntu-latest - steps: - - name: Generate Token - uses: actions/create-github-app-token@3378cda945da322a8db4b193e19d46352ebe2de5 # v1.10.4 - id: app-token - with: - app-id: "${{ secrets.BOT_APP_ID }}" - private-key: "${{ secrets.BOT_APP_PRIVATE_KEY }}" - - - name: Checkout - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - with: - token: "${{ steps.app-token.outputs.token }}" - - - name: Set up Go - uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 - with: - go-version: "1.22.x" - - - name: Login to GitHub Container Registry - uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0 - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GHCR_RW_TOKEN }} - - - name: Run GoReleaser - uses: goreleaser/goreleaser-action@286f3b13b1b49da4ac219696163fb8c1c93e1200 # v6.0.0 - with: - distribution: goreleaser - version: "~> v2" - args: release --clean ${{ env.DRY_RUN == 'true' && '--snapshot' || '' }} - env: - GITHUB_TOKEN: "${{ steps.app-token.outputs.token }}" diff --git a/.github/workflows/meta-label-sync.yaml b/.github/workflows/meta-label-sync.yaml index c05dec2..cda294d 100644 --- a/.github/workflows/meta-label-sync.yaml +++ b/.github/workflows/meta-label-sync.yaml @@ -10,48 +10,25 @@ on: default: true required: false type: boolean + pull_request: paths: - ".github/configs/labels.yaml" - ".github/workflows/meta-label-sync.yaml" + push: branches: ["main"] paths: - ".github/configs/labels.yaml" - ".github/workflows/meta-label-sync.yaml" + schedule: - cron: "0 0 * * *" # Every day at midnight -permissions: - issues: write - -env: - CONFIG_PATH: ".github/configs/labels.yaml" - DELETE_OTHER_LABELS: true - DRY_RUN: ${{ github.event_name == 'pull_request' || (github.event_name == 'workflow_dispatch' && github.event.inputs.dry-run == 'true') }} - jobs: label-sync: - runs-on: ubuntu-latest - - steps: - - name: Generate Token - uses: actions/create-github-app-token@3378cda945da322a8db4b193e19d46352ebe2de5 # v1.10.4 - id: app-token - with: - app-id: "${{ secrets.BOT_APP_ID }}" - private-key: "${{ secrets.BOT_APP_PRIVATE_KEY }}" - - - name: Checkout - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - with: - token: "${{ steps.app-token.outputs.token }}" - sparse-checkout: "${{ env.CONFIG_PATH }}" - - - name: Sync Labels - uses: EndBug/label-sync@52074158190acb45f3077f9099fea818aa43f97a # v2.3.3 - with: - token: "${{ steps.app-token.outputs.token }}" - config-file: "${{ env.CONFIG_PATH }}" - delete-other-labels: "${{ env.DELETE_OTHER_LABELS }}" - dry-run: "${{ env.DRY_RUN }}" + uses: mirceanton/reusable-workflows/.github/workflows/meta-label-sync.yaml@main@779974ececd8243d133c1813f429e3415712456b + secrets: inherit + with: + dry-run: ${{ github.event.inputs.dry-run || github.event_name == 'pull_request' }} + config-file: ".github/configs/labels.yaml" diff --git a/.github/workflows/meta-labeler.yaml b/.github/workflows/meta-labeler.yaml index cf7d9ee..3f49e43 100644 --- a/.github/workflows/meta-labeler.yaml +++ b/.github/workflows/meta-labeler.yaml @@ -6,39 +6,8 @@ on: pull_request_target: {} jobs: - size-label: - runs-on: ubuntu-latest - steps: - - name: Generate Token - uses: actions/create-github-app-token@3378cda945da322a8db4b193e19d46352ebe2de5 # v1.10.4 - id: app-token - with: - app-id: "${{ secrets.BOT_APP_ID }}" - private-key: "${{ secrets.BOT_APP_PRIVATE_KEY }}" - - - name: Size Label - uses: pascalgn/size-label-action@be08a2d5f857dc99c5b9426cdb5a8ea1aa7f0399 # v0.5.4 - env: - GITHUB_TOKEN: "${{ steps.app-token.outputs.token }}" - - labeler: - runs-on: ubuntu-latest - steps: - - name: Generate Token - uses: actions/create-github-app-token@3378cda945da322a8db4b193e19d46352ebe2de5 # v1.10.4 - id: app-token - with: - app-id: "${{ secrets.BOT_APP_ID }}" - private-key: "${{ secrets.BOT_APP_PRIVATE_KEY }}" - - - name: Checkout - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - with: - token: "${{ steps.app-token.outputs.token }}" - - - name: Labeler - uses: actions/labeler@8558fd74291d67161a8a78ce36a881fa63b766a9 # v5.0.0 - with: - configuration-path: ".github/configs/labeler.yaml" - repo-token: "${{ steps.app-token.outputs.token }}" - sync-labels: true + pr-labeler: + uses: mirceanton/reusable-workflows/.github/workflows/go-release.yaml@main@779974ececd8243d133c1813f429e3415712456b + secrets: inherit + with: + config-file: ".github/configs/labeler.yaml" diff --git a/.github/workflows/renovate.yaml b/.github/workflows/renovate.yaml index 6d27142..d61cf59 100644 --- a/.github/workflows/renovate.yaml +++ b/.github/workflows/renovate.yaml @@ -5,11 +5,11 @@ name: Renovate on: workflow_dispatch: inputs: - dryRun: + dry-run: description: Dry Run default: "false" required: false - logLevel: + log-level: description: Log Level default: debug required: false @@ -20,35 +20,10 @@ concurrency: group: ${{ github.workflow }}-${{ github.event.number || github.ref }} cancel-in-progress: true -env: - LOG_LEVEL: "${{ inputs.logLevel || 'debug' }}" - RENOVATE_AUTODISCOVER: true - RENOVATE_AUTODISCOVER_FILTER: "${{ github.repository }}" - RENOVATE_DRY_RUN: "${{ inputs.dryRun == true }}" - RENOVATE_PLATFORM: github - RENOVATE_PLATFORM_COMMIT: true - RENOVATE_VERSION: 37.367.0 - RENOVATE_GIT_AUTHOR: "mr-borboto[bot] <170036086+mr-borboto[bot]@users.noreply.github.com>" - jobs: renovate: - runs-on: "ubuntu-latest" - steps: - - name: Generate Token - uses: actions/create-github-app-token@3378cda945da322a8db4b193e19d46352ebe2de5 # v1.10.4 - id: app-token - with: - app-id: "${{ secrets.BOT_APP_ID }}" - private-key: "${{ secrets.BOT_APP_PRIVATE_KEY }}" - - - name: Checkout - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - with: - token: "${{ steps.app-token.outputs.token }}" - - - name: Renovate - uses: renovatebot/github-action@630a255a1f2f56c8d8ce160bed3e3ca577ca53e2 # v40.2.7 - with: - token: "${{ steps.app-token.outputs.token }}" - configurationFile: .github/renovate.json5 - renovate-version: "${{ env.WORKFLOW_RENOVATE_VERSION }}" + uses: mirceanton/reusable-workflows/.github/workflows/renovate.yaml@main + secrets: inherit + with: + dryRun: "${{ inputs.dry-run == true }}" + logLevel: "${{ inputs.log-level || 'debug' }}"