Skip to content

chore: define secrets #2

chore: define secrets

chore: define secrets #2

name: create-github-release

Check failure on line 1 in .github/workflows/create-github-release.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/create-github-release.yml

Invalid workflow file

(Line: 111, Col: 13): Unrecognized named-value: 'secrets'. Located at position 83 within expression: steps.changelog.outputs.skipped == 'true' && github.actor != 'dependabot[bot]' && secrets.CLI_ALERTS_SLACK_WEBHOOK != ''
on:
workflow_call:
secrets:
SVC_CLI_BOT_GITHUB_TOKEN:
description: A Github PAT with repo write access.
required: true
CLI_ALERTS_SLACK_WEBHOOK:
description: Slack webhook for alerts.
required: false
inputs:
prerelease:
type: string
description: "Name to use for the prerelease: beta, dev, etc."
skip-on-empty:
type: boolean
default: true
description: "Should release be skipped if there are no semantic commits?"
generate-readme:
type: boolean
default: true
description: "Generate oclif readme"
readme-multi:
type: boolean
description: "Create a different markdown page for each topic."
default: false
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Get Github user info
id: github-user-info
uses: salesforcecli/github-workflows/.github/actions/getGithubUserInfo@main
with:
SVC_CLI_BOT_GITHUB_TOKEN: ${{ secrets.SVC_CLI_BOT_GITHUB_TOKEN }}
- uses: actions/checkout@v4
with:
token: ${{ secrets.SVC_CLI_BOT_GITHUB_TOKEN }}
- uses: salesforcecli/github-workflows/.github/actions/getPreReleaseTag@main
id: distTag
- name: Validate prerelease
if: github.ref_name == 'main' && inputs.prerelease
uses: actions/github-script@v7
with:
script: |
core.setFailed('Do not create a prerelease on "main". You can create a prerelease on a branch and when it is merged it will create a non-prerelease Release. For example: 1.0.1-beta.2 will release as 1.0.1 when merged into main.')
- name: Determine prerelease name
id: prereleaseTag
# Only run this step if the ref is not main
# This will allow us to merge a prerelease PR into main and have it release as a normal release
if: github.ref_name != 'main'
run: |
if [ -n "$INPUTS_PRERELEASE" ]; then
echo "[INFO] Prerelease input passed in, using: $INPUTS_PRERELEASE"
echo "tag=$INPUTS_PRERELEASE" >> "$GITHUB_OUTPUT"
elif [ -n "$STEPS_DISTTAG_TAG" ]; then
echo "[INFO] Prerelease tag found in package.json, using: $STEPS_DISTTAG_TAG"
echo "tag=$STEPS_DISTTAG_TAG" >> "$GITHUB_OUTPUT"
elif [[ "$GITHUB_REF_NAME" =~ ^prerelease/.* ]]; then
echo "[INFO] Prerelease branch found but no prerelease tag, using default: dev"
echo "tag=dev" >> "$GITHUB_OUTPUT"
fi
env:
INPUTS_PRERELEASE: ${{ inputs.prerelease }}
STEPS_DISTTAG_TAG: ${{ steps.distTag.outputs.tag }}
- name: Generate oclif readme
if: ${{ inputs.generate-readme }}
uses: salesforcecli/github-workflows/.github/actions/generateOclifReadme@main
with:
skip-on-empty: ${{ inputs.skip-on-empty }}
pre-release: ${{ steps.prereleaseTag.outputs.tag && 'true' || 'false' }}
pre-release-identifier: ${{ steps.prereleaseTag.outputs.tag }}
multi: ${{ inputs.readme-multi }}
- name: Conventional Changelog Action
id: changelog
uses: TriPSs/conventional-changelog-action@3a392e9aa44a72686b0fc13259a90d287dd0877c
with:
git-user-name: ${{ steps.github-user-info.outputs.username }}
git-user-email: ${{ steps.github-user-info.outputs.email }}
github-token: ${{ secrets.SVC_CLI_BOT_GITHUB_TOKEN }}
tag-prefix: ""
# Setting 'release-count' to 0 will keep ALL releases in the change log file (no pruning)
release-count: "0"
skip-on-empty: ${{ inputs.skip-on-empty }}
pre-release: ${{ steps.prereleaseTag.outputs.tag && 'true' || 'false' }}
pre-release-identifier: ${{ steps.prereleaseTag.outputs.tag }}
# ternary-ish: https://github.com/actions/runner/issues/409#issuecomment-752775072
output-file: ${{ steps.prereleaseTag.outputs.tag && 'false' || 'CHANGELOG.md' }} # If prerelease, do not write the changelog file
- name: Create Github Release
uses: ncipollo/release-action@2c591bcc8ecdcd2db72b97d6147f871fcd833ba5
if: ${{ steps.changelog.outputs.skipped == 'false' }}
with:
name: ${{ steps.changelog.outputs.tag }}
tag: ${{ steps.changelog.outputs.tag }}
commit: ${{ github.ref_name }}
body: ${{ steps.changelog.outputs.clean_changelog }}
prerelease: ${{ steps.prereleaseTag.outputs.tag && 'true' || 'false' }}
token: ${{ secrets.SVC_CLI_BOT_GITHUB_TOKEN }}
skipIfReleaseExists: true
- name: Announce if Github Release was skipped
id: slack
if: ${{ steps.changelog.outputs.skipped == 'true' && github.actor != 'dependabot[bot]' && secrets.CLI_ALERTS_SLACK_WEBHOOK != '' }}
uses: slackapi/slack-github-action@v1.26.0
env:
# for non-CLI-team-owned plugins, you can send this anywhere you like
SLACK_WEBHOOK_URL: ${{ secrets.CLI_ALERTS_SLACK_WEBHOOK }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
with:
# Payload can be visually tested here: https://app.slack.com/block-kit-builder/T01GST6QY0G#%7B%22blocks%22:%5B%5D%7D
# Only copy over the "blocks" array to the Block Kit Builder
payload: |
{
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": ":uno-skip-red: Github Release was skipped in ${{ github.repository }}! :uno-skip-red:"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*Repo:* ${{ github.server_url }}/${{ github.repository }}\n*Workflow name:* `${{ github.workflow }}`\n*Run url:* ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
}
}
]
}