(Release): Build #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
name: "(Release): Build" | |
on: | |
release: | |
types: [created] | |
permissions: | |
contents: read | |
actions: read | |
jobs: | |
build: | |
uses: ./.github/workflows/build.yml | |
with: | |
ref: ${{ github.event.release.tag_name }} | |
upload: | |
needs: build | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
outputs: | |
zip_name: ${{ steps.zip.outputs.zip_name }} | |
steps: | |
- name: Download built zip | |
id: download | |
uses: actions/download-artifact@v4 | |
with: | |
artifact-ids: ${{ needs.build.outputs.artifact_id }} | |
path: ./bundle | |
- name: Create zip archive | |
id: zip | |
run: | | |
# zip filename format: <artifact_name>.<tag_name>.zip | |
zip_name="${{ needs.build.outputs.artifact_name }}.${{ github.event.release.tag_name }}.zip" | |
cd ./bundle/${{ needs.build.outputs.artifact_name }} | |
zip -r "../$zip_name" . | |
cd .. | |
echo "zip_name=$zip_name" >> $GITHUB_OUTPUT | |
echo "path=$(pwd)/$zip_name" >> $GITHUB_OUTPUT | |
- name: Upload release asset | |
id: upload | |
uses: softprops/action-gh-release@v2 | |
with: | |
files: ${{ steps.zip.outputs.path }} | |
deploy: | |
needs: [build, upload] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Dispatch publish workflow | |
env: | |
GH_TOKEN: ${{ secrets.CHANGELOG_PAT }} | |
run: | | |
target_repo="codesnippetspro/.github-private" | |
workflow_file="publish.yml" | |
echo "::notice::Dispatching publish workflow..." | |
echo " Repository: $target_repo" | |
echo " Source Repo: ${{ github.repository }}" | |
echo " Branch: ${{ github.ref_name }}" | |
echo " Tag: ${{ github.event.release.tag_name }}" | |
echo " Artifact Name: ${{ needs.build.outputs.artifact_name }}" | |
# Dispatch the workflow with required parameters | |
if ! gh workflow run "$workflow_file" \ | |
--repo "$target_repo" \ | |
--ref main \ | |
--field repo="${{ github.repository }}" \ | |
--field branch="${{ github.ref_name }}" \ | |
--field tag="${{ github.event.release.tag_name }}" \ | |
--field zip_name="${{ needs.upload.outputs.zip_name }}"; then | |
echo "::error::Failed to dispatch publish workflow in $target_repo" | |
exit 1 | |
fi | |
echo "::notice::Successfully dispatched publish workflow" | |
# Wait a moment for the run to be created | |
echo "Waiting for workflow run to be created..." | |
sleep 10 | |
# Get the workflow run URL for monitoring | |
if run_url=$(gh run list --repo "$target_repo" --workflow "$workflow_file" --limit 1 --json url -q '.[0].url' 2>/dev/null); then | |
echo "::notice::Monitor workflow progress at: $run_url" | |
echo "workflow_url=$run_url" >> $GITHUB_OUTPUT | |
fi | |