[build]correct terminology run_id to run_number and fix usage

master
Beq 2024-09-26 00:03:16 +01:00
parent f346e830ff
commit dfb216c367
2 changed files with 59 additions and 16 deletions

View File

@ -3,10 +3,9 @@ name: Deploy Viewer
on:
workflow_dispatch:
inputs:
build_run_id:
description: 'Workflow Run ID of the build to deploy'
build_run_number:
description: 'GitHub Run Number (per build_viewer.yml workflow)'
required: true
default: ''
viewer_channel:
description: 'viewer_channel'
required: true
@ -50,7 +49,7 @@ jobs:
id: download
with:
workflow: build_viewer.yml
run_number: ${{ github.event.inputs.build_run_id }}
run_number: ${{ github.event.inputs.build_run_number }}
path: to_deploy
- name: Install discord-webhook library
run: pip install discord-webhook

View File

@ -3,8 +3,8 @@ name: Tag FS Build
on:
workflow_dispatch:
inputs:
build_run_id:
description: 'GitHub Run ID'
build_run_number:
description: 'GitHub Run Number (per build_viewer.yml workflow)'
required: true
release_type:
description: "type of build"
@ -36,17 +36,61 @@ jobs:
runs-on: ubuntu-latest
steps:
# Step 1: Checkout the Repository
# Checkout the Repository
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Necessary to fetch all history for tagging
# Step 2: Install jq for JSON Parsing
# Install jq for JSON Parsing
- name: Install jq
run: sudo apt-get update && sudo apt-get install -y jq
# Step 3: Retrieve Run Information
# List Workflow Runs and Find run_id
- name: Find run_id from run_number
id: find_run_id
uses: octokit/request-action@v2.x
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
route: GET /repos/{owner}/{repo}/actions/workflows/build_viewer.yml/runs
owner: ${{ github.repository_owner }}
repo: ${{ github.event.repository.name }}
continue-on-error: false
# Extract run_id based on run_number
- name: Extract run_id
id: extract_run_id
run: |
run_number=${{ github.event.inputs.build_run_number }}
echo "Searching for run_number: $run_number"
# Parse the JSON response to find the run with the matching run_number
run_id=$(echo '${{ steps.find_run_id.outputs.data }}' | jq -r --arg RUN_NUMBER "$run_number" '.workflow_runs[] | select(.run_number == ($RUN_NUMBER | tonumber)) | .id')
if [ -z "$run_id" ]; then
echo "Error: No run found with run_number: $run_number"
exit 1
fi
echo "Found run_id: $run_id"
echo "run_id=$run_id" >> $GITHUB_OUTPUT
shell: bash
# Retrieve Run Information Using run_id
- name: Get run info
id: get_run_info
uses: octokit/request-action@v2.x
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
route: GET /repos/{owner}/{repo}/actions/runs/{run_id}
owner: ${{ github.repository_owner }}
repo: ${{ github.event.repository.name }}
run_id: ${{ steps.extract_run_id.outputs.run_id }}
continue-on-error: false
# Retrieve Run Information
- name: Get run info
id: get_run_info
uses: octokit/request-action@v2.x
@ -56,9 +100,9 @@ jobs:
route: GET /repos/{owner}/{repo}/actions/runs/{run_id}
owner: ${{ github.repository_owner }}
repo: ${{ github.event.repository.name }}
run_id: ${{ github.event.inputs.build_run_id }}
run_id: ${{ github.event.inputs.build_run_number }}
# Step 4: Extract Commit SHA and Branch from Run Info
# Extract Commit SHA and Branch from Run Info
- name: Extract commit SHA and branch
id: extract_info
run: |
@ -68,7 +112,7 @@ jobs:
echo "branch=$branch" >> $GITHUB_OUTPUT
shell: bash
# Step 4.1: (Optional) Check if Tag Already Exists
# Check if Tag Already Exists
- name: Check if tag exists
id: check_tag
run: |
@ -82,11 +126,11 @@ jobs:
fi
shell: bash
# Step 5: Checkout the Specific Commit
# Checkout the Specific Commit
- name: Checkout the specific commit
run: git checkout ${{ steps.extract_info.outputs.commit_sha }}
# Step 6: Create the Tag (Conditional)
# Create the Tag (Conditional)
- name: Create tag
id: create_tag
if: ${{ inputs.dry_run != 'true' && steps.check_tag.outputs.tag_exists == 'false' }}
@ -97,7 +141,7 @@ jobs:
echo "TAG_NAME=$TAG_NAME" >> $GITHUB_OUTPUT
shell: bash
# Step 7: Push the Tag to the Repository (Conditional)
# Push the Tag to the Repository (Conditional)
- name: Push tag
if: ${{ inputs.dry_run != 'true' && steps.check_tag.outputs.tag_exists == 'false' }}
env:
@ -105,7 +149,7 @@ jobs:
run: |
git push origin ${{ steps.create_tag.outputs.TAG_NAME }}
# Step 8: Output Dry Run or Tag Creation Message
# Output Dry Run or Tag Creation Message
- name: Tagging Confirmation
run: |
TAG_NAME="Firestorm_${{ github.event.inputs.release_type }}_${{ github.event.inputs.viewer_version }}.${{ github.event.inputs.viewer_build }}"