Draft Engine Release #242
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: Draft Engine Release | |
on: | |
workflow_dispatch: | |
inputs: | |
wf-run-id: | |
description: Workflow Run Id to Upload | |
required: true | |
default: "latest" | |
release-tag: | |
description: Release Name/Tag | |
required: false | |
default: "" | |
jobs: | |
release: | |
name: Release Engine | |
runs-on: ubuntu-latest | |
steps: | |
- name: Install Build Dependencies (Common) | |
run: | | |
sudo apt-get update -y | |
sudo apt-get install --fix-missing -y curl unzip | |
# - name: Setup tmate session | |
# uses: mxschmitt/action-tmate@v3 | |
- name: Download Artifacts | |
id: dl-artifacts | |
run: | | |
if [ "${{ github.event.inputs.wf-run-id }}" == "latest" ]; then | |
run_id=$(curl -X GET -u "${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}" -s 'https://api.github.com/repos/${{ github.repository }}/actions/workflows/build-docker.yml/runs?status=success&per_page=1' | jq '.workflow_runs[0].id') | |
if [ "$run_id" == "null" ]; then | |
echo "Failed to fetch latest runs" | |
exit 1 | |
fi | |
else | |
run_id="${{ github.event.inputs.wf-run-id }}" | |
fi | |
get_code=$(curl -X GET -u "${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}" -s -o /dev/null -w "%{http_code}" "https://api.github.com/repos/${{ github.repository }}/actions/runs/${run_id}") | |
if [ $get_code != 200 ]; then | |
echo "Failed to fetch run $run_id" | |
exit 1 | |
fi | |
echo "Creating release from run $run_id" | |
artifact_dl_urls=$(curl -X GET -u "${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}" -s "https://api.github.com/repos/${{ github.repository }}/actions/runs/${run_id}/artifacts" | jq ".artifacts[].archive_download_url" | tr -d "\"") | |
for adl in $artifact_dl_urls; do | |
curl -X GET -u "${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}" -L -s -o tmp.zip $adl | |
unzip tmp.zip | |
rm tmp.zip | |
done | |
if [ "${{ github.event.inputs.release-tag }}" == "" ]; then | |
filename=$(ls | grep spring | head -n 1) | |
release_tag=$(echo $filename | cut -d'_' -f1,2,3) | |
echo "release_tag=${release_tag}" >> "$GITHUB_OUTPUT" | |
else | |
echo "release_tag=${{ github.event.inputs.release-tag }}" >> "$GITHUB_OUTPUT" | |
fi | |
shell: bash | |
- name: Upload Artifacts As Release | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: ./* | |
tag_name: ${{ steps.dl-artifacts.outputs.release_tag }} | |
body: "Github Action Upload" | |
draft: true |