Skip to content

Scheduled sycl-rel-nightly launch #158

Scheduled sycl-rel-nightly launch

Scheduled sycl-rel-nightly launch #158

# Github Actions launch scheduled workflows of the main branch only (sycl).
# This is a workaround to set a scheduled launch of the sycl-rel-nightly.yml
# workflow, which is located on the sycl-rel-* branch.
name: Scheduled sycl-rel-nightly launch
permissions: read-all
on:
schedule:
- cron: '0 3 * * *'
workflow_dispatch:
jobs:
launch:
if: github.repository == 'intel/llvm'
permissions:
actions: write
runs-on: ubuntu-latest
strategy:
# Keep the matrix even if there is only one branch.
matrix:
branch: [sycl-rel-6_2, sycl-rel-6_3]
steps:
- name: Launch for ${{ matrix.branch }}
env:
GH_TOKEN: ${{ github.token }}
BRANCH: ${{ matrix.branch }}
# To avoid excessive runs this script checks if there are new commits
# since the last run - it checks if the latest commit is older >24h.
# That means the previous run has already tested this commit.
run: |
BRANCH="${{ matrix.branch }}"
if [ "$GITHUB_EVENT_NAME" = "schedule" ]; then
latest_commit_time=$(curl -s -H "Authorization: token $GH_TOKEN" https://api.github.com/repos/intel/llvm/commits/{$BRANCH} | jq -r '.commit.committer.date')
echo $latest_commit_time
latest_commit_epoch=$(date -d "$latest_commit_time" +%s)
now_epoch=$(date +%s)
diff=$((now_epoch - latest_commit_epoch))
if [ "$diff" -lt 86400 ]; then
gh workflow run sycl-rel-nightly.yml --repo "${GITHUB_REPOSITORY}" --ref "${BRANCH}"
fi
else
gh workflow run sycl-rel-nightly.yml --repo "${GITHUB_REPOSITORY}" --ref "${BRANCH}"
fi