Separate out validate and publish steps to actions #1
Workflow file for this run
This file contains hidden or 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
| on: | ||
|
Check failure on line 1 in .github/workflows/publish-javascript-github-v1.yml
|
||
| workflow_call: | ||
| inputs: | ||
| expected_pkg_name: | ||
| description: > | ||
| Expected package.json name. If provided, must match. | ||
| type: string | ||
| required: false | ||
| expected_pkg_version: | ||
| description: > | ||
| Expected package.json version. If provided, must match. | ||
| May include optional leading 'v' (e.g. v1.2.3). | ||
| type: string | ||
| required: false | ||
| dist_tag: | ||
| description: 'Dist tag to release e.g., latest, alpha, beta, rc, etc.' | ||
| type: string | ||
| required: false | ||
| node_auth_token: | ||
| description: > | ||
| Token used to authenticate to GitHub Packages (usually GITHUB_TOKEN). | ||
| type: string | ||
| required: false | ||
| default: ${{ secrets.GITHUB_TOKEN }} | ||
| dry_run: | ||
| description: 'Run all checks but do not actually publish packages.' | ||
| type: boolean | ||
| required: false | ||
| default: false | ||
| cwd: | ||
| description: > | ||
| Working directory containing package.json (relative to repo root). | ||
| type: string | ||
| required: false | ||
| default: "." | ||
| runner_label: | ||
| description: 'Label for the runner to be used for the jobs.' | ||
| default: 'ubuntu-latest' | ||
| required: false | ||
| type: string | ||
| jobs: | ||
| publish-javascript-github: | ||
| runs-on: ${{ inputs.runner_label }} | ||
| permissions: | ||
| contents: read | ||
| packages: write | ||
| steps: | ||
| - name: Checkout repository contents | ||
| uses: actions/checkout@v6 | ||
| - name: Set up Node.js | ||
| uses: actions/setup-node@v6 | ||
| with: | ||
| node-version: 'lts/*' | ||
| - name: Install npm dependencies | ||
| shell: bash | ||
| run: npm ci | ||
| - name: Publish to GitHub Packages | ||
| id: publish_github | ||
| uses: fastly/devex-reusable-workflows/actions/publish-javascript-github-v1@kats/publish-javascript-packages | ||
| with: | ||
| expected_pkg_name: ${{ inputs.expected_pkg_name }} | ||
| expected_pkg_version: ${{ inputs.expected_pkg_version }} | ||
| dist_tag: ${{ inputs.dist_tag }} | ||
| node_auth_token: ${{ secrets.GITHUB_TOKEN }} | ||
| dry_run: ${{ inputs.dry_run }} | ||
| cwd: ${{ inputs.cwd }} | ||
| - name: Publish status | ||
| if: always() | ||
| shell: bash | ||
| run: | | ||
| set -euo pipefail | ||
| if [[ '${{ inputs.dry_run }}' == 'true' ]]; then | ||
| echo "::notice::Dry run enabled — no package was actually published." | ||
| exit 0 | ||
| fi | ||
| echo "github outcome: ${{ steps.publish_github.outcome || 'skipped' }}" | ||
| if [[ "${{ steps.publish_github.outcome }}" == 'failure' ]]; then | ||
| echo "::error::Publish to GitHub Packages failed." | ||
| echo "::notice::Hint: Ensure the caller repo/workflow is able to write this package." | ||
| exit 1 | ||
| fi | ||