2021-03-27 16:23:38 +00:00
name : Schedule Trigger
on :
schedule :
- cron : '0 6 * * *'
2021-03-29 06:55:08 +00:00
workflow_dispatch :
2021-03-27 16:23:38 +00:00
jobs :
Release-Nightly :
runs-on : ubuntu-latest
env :
GIT_BRANCH : "development"
WORKFLOW_TO_TRIGGER : "release_beta_to_dev.yaml"
steps :
2021-03-29 10:51:50 +00:00
- name : Get Latest Version
id : latest-version
2021-03-27 16:23:38 +00:00
run : |
echo "**** Checking branch ${{ env.GIT_BRANCH }} ****"
2021-03-29 10:51:50 +00:00
LATEST_VERSION=$(git ls-remote https://github.com/${{ github.repository }}.git refs/heads/${{ env.GIT_BRANCH }} | cut -f1)
2021-03-27 16:23:38 +00:00
if [[ $? != 0 ]]; then
echo "**** Cannot get latest hash from GitHub, exiting... ****"
exit 1
fi
echo "**** Latest version: $LATEST_VERSION ****"
2021-03-29 10:51:50 +00:00
echo "::set-output name=LATEST_VERSION::$LATEST_VERSION"
- name : Get Last Trigger Cache
id : cache
uses : actions/cache@v2
with :
path : ./LAST_VERSION_SAVED
key : bazarr-${{ env.GIT_BRANCH }}-${{ env.WORKFLOW_TO_TRIGGER }}-${{ steps.latest-version.outputs.LATEST_VERSION }}
- name : Execute
if : steps.cache.outputs.cache-hit != 'true'
run : |
echo "**** Trigging ${{ env.WORKFLOW_TO_TRIGGER }} of branch ${{ env.GIT_BRANCH }} ****"
FILE_TO_WRITE='./LAST_VERSION_SAVED'
if curl -sfX GET https://raw.githubusercontent.com/${{ github.repository }}/${{ env.GIT_BRANCH }}/.github/workflows/${{ env.WORKFLOW_TO_TRIGGER }} > /dev/null 2>&1; then
echo "**** Workflow exists. Triggering workflow for branch ${{ env.GIT_BRANCH }} ****"
curl -ifX POST \
-H "Authorization: token ${{ secrets.WF_GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
-d "{\"ref\":\"refs/heads/${{ env.GIT_BRANCH }}\"}" \
https://api.github.com/repos/${{ github.repository }}/actions/workflows/${{ env.WORKFLOW_TO_TRIGGER }}/dispatches
echo "1" > $FILE_TO_WRITE
2021-03-27 16:23:38 +00:00
else
2021-03-29 10:51:50 +00:00
echo "**** Workflow doesn't exist! Skipping... ****"
2021-03-27 16:23:38 +00:00
fi