no log: Fix caches issue in schedule trigger action

pull/1370/head
Liang Yi 4 years ago committed by GitHub
parent bcf31196ba
commit 43254291f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -9,43 +9,39 @@ jobs:
Release-Nightly: Release-Nightly:
runs-on: ubuntu-latest runs-on: ubuntu-latest
env: env:
GITHUB_REPO: "morpheus65535/bazarr"
GIT_BRANCH: "development" GIT_BRANCH: "development"
WORKFLOW_TO_TRIGGER: "release_beta_to_dev.yaml" WORKFLOW_TO_TRIGGER: "release_beta_to_dev.yaml"
steps: steps:
- name: Get Previous Version - name: Get Latest Version
uses: actions/cache@v2 id: latest-version
with:
path: ./LAST_VERSION_SAVED
key: bazarr-${{ env.GIT_BRANCH }}-${{ env.WORKFLOW_TO_TRIGGER }}-trigger
- name: Execute
run: | run: |
echo "**** Checking branch ${{ env.GIT_BRANCH }} ****" echo "**** Checking branch ${{ env.GIT_BRANCH }} ****"
LATEST_VERSION=$(git ls-remote https://github.com/${{ env.GITHUB_REPO }}.git refs/heads/${{ env.GIT_BRANCH }} | cut -f1) LATEST_VERSION=$(git ls-remote https://github.com/${{ github.repository }}.git refs/heads/${{ env.GIT_BRANCH }} | cut -f1)
if [[ $? != 0 ]]; then if [[ $? != 0 ]]; then
echo "**** Cannot get latest hash from GitHub, exiting... ****" echo "**** Cannot get latest hash from GitHub, exiting... ****"
exit 1 exit 1
fi fi
FILE_TO_CHECK='./LAST_VERSION_SAVED'
PREV_VERSION=0
[[ -f $FILE_TO_CHECK ]] && PREV_VERSION=$(cat $FILE_TO_CHECK)
echo "**** Previous version: $PREV_VERSION ****"
echo "**** Latest version: $LATEST_VERSION ****" echo "**** Latest version: $LATEST_VERSION ****"
echo $LATEST_VERSION > $FILE_TO_CHECK echo "::set-output name=LATEST_VERSION::$LATEST_VERSION"
if [[ 16#$LATEST_VERSION -eq 16#$PREV_VERSION ]]; then - name: Get Last Trigger Cache
echo "**** No Changes Found ****" 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
else else
echo "**** Changes Found ****" echo "**** Workflow doesn't exist! Skipping... ****"
if curl -sfX GET https://raw.githubusercontent.com/${{ env.GITHUB_REPO }}/${{ 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 -iX 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/${{ env.GITHUB_REPO }}/actions/workflows/${{ env.WORKFLOW_TO_TRIGGER }}/dispatches
else
echo "**** Workflow doesn't exist! Skipping... ****"
fi
fi fi

Loading…
Cancel
Save