-
Notifications
You must be signed in to change notification settings - Fork 305
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
26 additions
and
48 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,8 +9,11 @@ on: | |
commit_sha: | ||
description: 'Commit SHA to deploy' | ||
required: true | ||
environment_name: | ||
description: 'Environment to deploy to' | ||
required: true | ||
|
||
concurrency: staging | ||
concurrency: ${{ github.event.inputs.environment_name }} | ||
|
||
env: | ||
build_workflow_name: build.yml | ||
|
@@ -23,46 +26,32 @@ jobs: | |
steps: | ||
- name: Print inputs | ||
run: | | ||
echo "Branch: ${{ github.event.inputs.branch_name }}" | ||
echo "Branch: ${{ github.event.inputs.environment_name }}" | ||
echo "Commit SHA: ${{ github.event.inputs.commit_sha }}" | ||
- name: Get workflow runs for commit | ||
- name: Get workflow runs for the specific branch and commit | ||
id: get_workflow_run | ||
uses: octokit/[email protected] | ||
with: | ||
# Remove the event filter to get all events | ||
route: GET /repos/${{ github.repository }}/actions/workflows/${{ env.build_workflow_name }}/runs?branch=${{ github.event.inputs.branch_name }} | ||
route: GET /repos/${{ github.repository }}/actions/workflows/${{ env.build_workflow_name }}/runs?branch=${{ github.event.inputs.branch_name }}&head_sha=${{ github.event.inputs.commit_sha }} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Find build for specific commit | ||
id: set_build_workflow_id | ||
run: | | ||
COMMIT_SHA="${{ github.event.inputs.commit_sha }}" | ||
WORKFLOW_DATA='${{ steps.get_workflow_run.outputs.data }}' | ||
# Find the workflow run for the specific commit across all supported events | ||
WORKFLOW_ID=$(echo "$WORKFLOW_DATA" | jq -r --arg COMMIT "$COMMIT_SHA" ' | ||
.workflow_runs[] | ||
| select( | ||
.head_sha == $COMMIT and ( | ||
# List all events that can trigger builds | ||
.event == "push" or | ||
.event == "pull_request" or | ||
.event == "release" or | ||
.event == "workflow_dispatch" or | ||
.event == "schedule" | ||
) | ||
) | ||
| .id | ||
' | head -n1) # Get the first matching workflow | ||
WORKFLOW_ID=$(echo "$WORKFLOW_DATA" | jq -r ' | ||
.workflow_runs[0].id // empty | ||
') | ||
if [ -z "$WORKFLOW_ID" ]; then | ||
echo "::error::No build found for commit $COMMIT_SHA on branch ${{ github.event.inputs.branch_name }}" | ||
echo "::error::No build found for commit ${{ github.event.inputs.commit_sha }} on branch ${{ github.event.inputs.branch_name }}" | ||
exit 1 | ||
fi | ||
echo "Found build workflow ID: $WORKFLOW_ID for commit $COMMIT_SHA" | ||
echo "Found build workflow ID: $WORKFLOW_ID for commit ${{ github.event.inputs.commit_sha }} on branch ${{ github.event.inputs.branch_name }}" | ||
echo "workflow_id=$WORKFLOW_ID" >> $GITHUB_OUTPUT | ||
- name: Check for war artifact | ||
|
@@ -89,7 +78,7 @@ jobs: | |
needs: check-build-status | ||
runs-on: [self-hosted, ase-large-ubuntu] | ||
environment: | ||
name: artemis-staging-localci.artemis.cit.tum.de | ||
name: ${{ github.event.inputs.environment_name }} | ||
url: ${{ vars.DEPLOYMENT_URL }} | ||
env: | ||
DEPLOYMENT_HOSTS_PRIMARY: ${{ vars.DEPLOYMENT_HOSTS_PRIMARY }} | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,8 +9,11 @@ on: | |
commit_sha: | ||
description: 'Commit SHA to deploy' | ||
required: true | ||
environment_name: | ||
description: 'Environment to deploy to' | ||
required: true | ||
|
||
concurrency: staging | ||
concurrency: ${{ github.event.inputs.environment_name }} | ||
|
||
env: | ||
build_workflow_name: build.yml | ||
|
@@ -23,46 +26,32 @@ jobs: | |
steps: | ||
- name: Print inputs | ||
run: | | ||
echo "Branch: ${{ github.event.inputs.branch_name }}" | ||
echo "Branch: ${{ github.event.inputs.environment_name }}" | ||
echo "Commit SHA: ${{ github.event.inputs.commit_sha }}" | ||
- name: Get workflow runs for commit | ||
- name: Get workflow runs for the specific branch and commit | ||
id: get_workflow_run | ||
uses: octokit/[email protected] | ||
with: | ||
# Remove the event filter to get all events | ||
route: GET /repos/${{ github.repository }}/actions/workflows/${{ env.build_workflow_name }}/runs?branch=${{ github.event.inputs.branch_name }} | ||
route: GET /repos/${{ github.repository }}/actions/workflows/${{ env.build_workflow_name }}/runs?branch=${{ github.event.inputs.branch_name }}&head_sha=${{ github.event.inputs.commit_sha }} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Find build for specific commit | ||
id: set_build_workflow_id | ||
run: | | ||
COMMIT_SHA="${{ github.event.inputs.commit_sha }}" | ||
WORKFLOW_DATA='${{ steps.get_workflow_run.outputs.data }}' | ||
# Find the workflow run for the specific commit across all supported events | ||
WORKFLOW_ID=$(echo "$WORKFLOW_DATA" | jq -r --arg COMMIT "$COMMIT_SHA" ' | ||
.workflow_runs[] | ||
| select( | ||
.head_sha == $COMMIT and ( | ||
# List all events that can trigger builds | ||
.event == "push" or | ||
.event == "pull_request" or | ||
.event == "release" or | ||
.event == "workflow_dispatch" or | ||
.event == "schedule" | ||
) | ||
) | ||
| .id | ||
' | head -n1) # Get the first matching workflow | ||
WORKFLOW_ID=$(echo "$WORKFLOW_DATA" | jq -r ' | ||
.workflow_runs[0].id // empty | ||
') | ||
if [ -z "$WORKFLOW_ID" ]; then | ||
echo "::error::No build found for commit $COMMIT_SHA on branch ${{ github.event.inputs.branch_name }}" | ||
echo "::error::No build found for commit ${{ github.event.inputs.commit_sha }} on branch ${{ github.event.inputs.branch_name }}" | ||
exit 1 | ||
fi | ||
echo "Found build workflow ID: $WORKFLOW_ID for commit $COMMIT_SHA" | ||
echo "Found build workflow ID: $WORKFLOW_ID for commit ${{ github.event.inputs.commit_sha }} on branch ${{ github.event.inputs.branch_name }}" | ||
echo "workflow_id=$WORKFLOW_ID" >> $GITHUB_OUTPUT | ||
- name: Check for war artifact | ||
|
@@ -89,7 +78,7 @@ jobs: | |
needs: check-build-status | ||
runs-on: [self-hosted, ase-large-ubuntu] | ||
environment: | ||
name: artemis-staging-localci.artemis.cit.tum.de | ||
name: ${{ github.event.inputs.environment_name }} | ||
url: ${{ vars.DEPLOYMENT_URL }} | ||
env: | ||
DEPLOYMENT_HOSTS_PRIMARY: ${{ vars.DEPLOYMENT_HOSTS_PRIMARY }} | ||
|