Skip to content

if var expansion

if var expansion #43

Workflow file for this run

# This is a basic workflow to help you get started with Actions
name: CI
# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
branches: [ main ]
pull_request:
branches: [ main ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
trigger_on_integration_test:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: trigger Job
id: trigger-job
env:
URL: ${{ secrets.url }}
PROJECT_ID: ${{ secrets.project_id }}
TRIGGER_TOKEN: ${{ secrets.trigger_token }}
REF_NAME: ${{ secrets.ref_name }}
USER_AGENT: ${{ secrets.user_agent }}
shell: bash
run: |
# Fail if no token
test -n "${TRIGGER_TOKEN}" || echo "::warning ::No secret token was set!"
# Print webhook call
echo curl -X POST \
--fail \
-o response.json \
-F "token=${TRIGGER_TOKEN}" \
-F "ref=${REF_NAME}" \
-A "${USER_AGENT}" \
${variable_args} \
${URL}/api/v4/projects/${PROJECT_ID}/trigger/pipeline
# Call webhook
curl -X POST \
--fail \
-o response.json \
-F "token=${TRIGGER_TOKEN}" \
-F "ref=${REF_NAME}" \
-A "${USER_AGENT}" \
${variable_args} \
${URL}/api/v4/projects/${PROJECT_ID}/trigger/pipeline
# Print and parse json
jq . response.json
echo "json=$(cat response.json)" >> $GITHUB_OUTPUT
echo "id=$(cat response.json | jq -c '.id')" >> $GITHUB_OUTPUT
- name: check pipeline
id: check-pipeline
env:
URL: ${{ secrets.url }}
PROJECT_ID: ${{ secrets.project_id }}
ACCESS_TOKEN: ${{ secrets.access_token }}
REF_NAME: ${{ secrets.ref_name }}
USER_AGENT: ${{ secrets.user_agent }}
ID: ${{ steps.trigger-job.outputs.id }}
shell: bash
run: |
# Fail if no token
test -n "${ACCESS_TOKEN}" || echo "::warning ::No secret token was set!"
# Print webhook call
echo curl \
--fail \
-o response.json \
-H "PRIVATE-TOKEN: ${ACCESS_TOKEN}" \
-A "${USER_AGENT}" \
${URL}/api/v4/projects/${PROJECT_ID}/pipelines/${ID}
sleep 30
for i in {1..20} ; do
# Call webhook
curl \
--fail \
-o response.json \
-H "PRIVATE-TOKEN: ${ACCESS_TOKEN}" \
-A "${USER_AGENT}" \
${URL}/api/v4/projects/${PROJECT_ID}/pipelines/${ID}
# check status for success
status=$(cat response.json | jq -c '.status')
if [[ "$status" == "success" ]] ; then
break
fi
sleep 60
done
jq . response.json
jq -c '.status'
echo "json=$(cat response.json)" >> $GITHUB_OUTPUT
echo "status=$(cat response.json | jq -c '.status')" >> $GITHUB_OUTPUT