Skip to content

Commit

Permalink
simplify release action and sort the workflow actions to select the n…
Browse files Browse the repository at this point in the history
…ewest
  • Loading branch information
paulbkoch committed Jul 30, 2024
1 parent c41519a commit 8300e27
Showing 1 changed file with 4 additions and 17 deletions.
21 changes: 4 additions & 17 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,6 @@ on:
- published
workflow_dispatch:
inputs:
version:
description: 'Release version'
required: true
environment:
description: 'Deployment environment'
required: true
default: 'production'
commit_id:
description: 'Commit ID (required for manual trigger)'
required: true
Expand All @@ -21,26 +14,20 @@ jobs:
publish_packages:
runs-on: ubuntu-latest
steps:
- name: Set commit ID
id: set_commit_id
- name: Find CI workflow run by commit ID
id: find_workflow
run: |
if [ "${{ github.event_name }}" == "release" ]; then
commit_id="${{ github.event.release.target_commitish }}"
else
commit_id="${{ github.event.inputs.commit_id }}"
fi
echo "Commit ID: ${commit_id}"
echo "::set-output name=commit_id::${commit_id}"
- name: Find workflow run by commit ID
id: find_workflow
run: |
commit_id="${{ steps.set_commit_id.outputs.commit_id }}"
if [ -z "$commit_id" ]; then
echo "Error: commit_id is empty."
exit 1
fi
echo "Commit ID: ${commit_id}"
workflow_runs=$(gh api -X GET "/repos/${{ github.repository }}/actions/runs?event=push&status=success" -q '.workflow_runs[] | select(.head_commit.id=="'${commit_id}'")')
workflow_runs=$(gh api -X GET "/repos/${{ github.repository }}/actions/runs?event=push&status=success" -q '.workflow_runs[] | select(.head_commit.id=="'${commit_id}'") | sort_by(.created_at) | reverse | .[0]')
run_id=$(echo "$workflow_runs" | jq -r '.id')
echo "Run ID: ${run_id}"
echo "::set-output name=run_id::${run_id}"
Expand All @@ -50,6 +37,6 @@ jobs:
uses: actions/download-artifact@v4
with:
run-id: ${{ steps.find_workflow.outputs.run_id }}
github-token: ${{secrets.GITHUB_TOKEN}}
github-token: ${{ secrets.GITHUB_TOKEN }}
name: npm
path: bld/npm

0 comments on commit 8300e27

Please sign in to comment.