add step security #180
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: "Release" | ||
on: | ||
push: | ||
branches: | ||
- main | ||
workflow_dispatch: | ||
permissions: | ||
contents: write | ||
packages: write | ||
pull-requests: write | ||
jobs: | ||
release: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1 | ||
with: | ||
egress-policy: audit | ||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | ||
with: | ||
fetch-depth: 0 | ||
persist-credentials: false | ||
- uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0 | ||
with: | ||
node-version: 20 | ||
always-auth: true | ||
registry-url: "https://registry.npmjs.org" | ||
- name: Install dependencies | ||
run: yarn --frozen-lockfile | ||
- name: Run checks | ||
run: yarn run test && yarn lint && yarn build | ||
# Use an app to authenticate to trigger workflows on the repository | ||
- name: Get app installation token | ||
uses: actions/create-github-app-token@5d869da34e18e7287c1daad50e0b8ea0f506ce69 # v1.11.0 | ||
id: app-token | ||
with: | ||
app-id: ${{ vars.APP_ID }} | ||
private-key: ${{ secrets.APP_PRIVATE_KEY }} | ||
- uses: googleapis/release-please-action@7987652d64b4581673a76e33ad5e98e3dd56832f # v.1.3 | ||
id: release | ||
with: | ||
token: ${{ steps.app-token.outputs.token }} | ||
release-type: node | ||
- name: Publish to NPM | ||
id: npm_publish | ||
if: ${{ steps.release.outputs.release_created }} | ||
run: | | ||
yarn pack | ||
# get sha256 and set output | ||
echo "sha256=$(shasum -a 256 action-docs-*.tgz | cut -d ' ' -f 1)" >> $GITHUB_ENV yarn publish | ||
yarn publish | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
outputs: | ||
release_created: ${{ steps.release.outputs.release_created }} | ||
relase_version: ${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }}.${{ steps.release.outputs.patch }} | ||
release_tag: ${{ steps.release.outputs.tag_name }} | ||
release_sha256: ${{ steps.npm_publish.outputs.sha256 }} | ||
homebrew: | ||
if: ${{ needs.release.outputs.release_created }} | ||
name: "Bump Homebrew formula" | ||
runs-on: ubuntu-latest | ||
needs: release | ||
steps: | ||
- uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1 | ||
with: | ||
egress-policy: audit | ||
- uses: npalm/bump-homebrew-formula-action@c03eb3e9122887190a202b7dc42edba8031ed0f9 | ||
with: | ||
# A PR will be sent to github.com/Homebrew/homebrew-core to update this formula | ||
formula-name: action-docs | ||
formula-path: Formula/a/action-docs.rb | ||
tag-name: ${{ needs.release.outputs.release_tag }} | ||
download-url: https://registry.npmjs.org/action-docs/-/action-docs-${{ needs.release.outputs.release_version }}.tgz | ||
download-sha256: ${{ needs.release.outputs.release_sha256 }} | ||
commit-message: | | ||
Bump action-docs to v${{ needs.release.outputs.release_version }} | ||
see: https://github.com/npalm/action-docs/releases/tag/${{ needs.release.outputs.release_tag }} | ||
env: | ||
COMMITTER_TOKEN: ${{ secrets.HOMEBREW_GITHUB_TOKEN }} |