chore(deps): update actions/checkout action to v4.2.0 (#658) #1545
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
name: main | |
'on': | |
push: | |
branches: [main, 'renovate/**'] | |
pull_request: | |
types: [opened, synchronize, reopened, ready_for_review] | |
workflow_dispatch: | |
inputs: | |
dry_run: | |
description: 'Dry run' | |
default: true | |
required: false | |
type: boolean | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.number || github.ref }} | |
cancel-in-progress: true | |
permissions: | |
contents: read | |
jobs: | |
lint: | |
name: Lint | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 | |
- name: Setup pnpm | |
uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # v4.0.0 | |
- name: Setup Node.js | |
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3 | |
with: | |
cache: 'pnpm' | |
node-version-file: '.node-version' | |
- name: Install dependencies | |
run: pnpm install --frozen-lockfile --ignore-scripts | |
- name: Check formatting | |
run: pnpm run check-format | |
release: | |
env: | |
DRY_RUN: true | |
name: Release | |
needs: [lint] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Get Wokrflow Application Token | |
id: get-workflow-app-token | |
uses: peter-murray/workflow-application-token-action@dc0413987a085fa17d19df9e47d4677cf81ffef3 # v3.0.0 | |
with: | |
application_id: ${{ secrets.APPLICATION_ID }} | |
application_private_key: ${{ secrets.APPLICATION_PRIVATE_KEY }} | |
permissions: 'contents:write, issues:write, pull_requests:write, workflows:write' | |
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 | |
with: | |
ref: ${{ github.head_ref }} | |
token: ${{ steps.get-workflow-app-token.outputs.token }} | |
- name: Setup pnpm | |
uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # v4.0.0 | |
- name: Setup Node.js | |
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3 | |
with: | |
cache: 'pnpm' | |
node-version-file: '.node-version' | |
- name: Install dependencies | |
run: pnpm install --frozen-lockfile | |
- name: Get Release Options | |
env: | |
INPUT_DRY_RUN: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.dry_run && 'true' || 'false' }} | |
IS_DEFAULT_BRANCH: ${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }} | |
run: | | |
if [[ $INPUT_DRY_RUN != 'true' || $IS_DEFAULT_BRANCH == 'true' ]]; then | |
echo "DRY_RUN=false" >> $GITHUB_ENV | |
fi | |
- name: Semantic Release | |
id: semantic-release | |
env: | |
GIT_AUTHOR_EMAIL: '137683033+mrbro-bot[bot]@users.noreply.github.com' | |
GIT_AUTHOR_NAME: 'mrbro-bot[bot]' | |
GIT_COMMITTER_EMAIL: '137683033+mrbro-bot[bot]@users.noreply.github.com' | |
GIT_COMMITTER_NAME: 'mrbro-bot[bot]' | |
GITHUB_TOKEN: ${{ steps.get-workflow-app-token.outputs.token }} | |
run: | | |
# The semantic-release config creates outputs to indicate whether a new release was published and if so, which version. | |
pnpm exec semantic-release --dry-run ${{ env.DRY_RUN }} --ci ${{ env.DRY_RUN != 'true' }} | |
shell: 'bash -Eeuxo pipefail {0}' | |
- name: Push Release Branch To Major Branch | |
if: ${{ env.DRY_RUN != 'true' && steps.semantic-release.outputs.new-release-published == 'true' }} | |
env: | |
GH_REPO: ${{ github.repository }} | |
GH_TOKEN: ${{ steps.get-workflow-app-token.outputs.token }} | |
run: | | |
# Update the major branch reference to the new release tag | |
version=${{ steps.semantic-release.outputs.new-release-version }} | |
sha=$(gh api repos/{owner}/{repo}/git/ref/tags/v${version} | jq -r .object.sha) | |
branch_name=v$(echo ${version} | cut -d . -f 1) | |
ref=refs/heads/${branch_name} | |
if [[ "$(gh api repos/{owner}/{repo}/git/ref/heads/${branch_name} 2>&1)" =~ "Not Found" ]]; then | |
gh api -X POST repos/{owner}/{repo}/git/refs -f ref=${ref} -f sha=$sha | |
else | |
gh api -X PATCH repos/{owner}/{repo}/git/${ref} -f sha=$sha -F force=true | |
fi | |
shell: 'bash -Eeuxo pipefail {0}' |