Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions .github/workflows/update-haf-tfa.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
# This workflow automates the process of updating the HAF/TF-A binaries external dependency in this repository.
#
# This workflow will run on a weekly schedule and will search for the latest release that has occurred in the last 7
# days. If a new release is found, it will create a PR to update the external dependency file and set the
# `HAF_TFA_EXTDEP_BINS_CURRENT` variable to True in the PlatformBuild.py file. If a PR exists for an older release,
# it will be closed in favor of the new PR.
# This workflow triggers automatically after the Hafnium and Trusted Firmware-A Build workflow completes successfully
# on a release event, ensuring the binaries are already uploaded before this workflow runs. It will create a PR to
# update the external dependency files and set the `HAF_TFA_EXTDEP_BINS_CURRENT` variable to True in the
# PlatformBuild.py file. If a PR exists for an older release, it will be closed in favor of the new PR.
##
# Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
##
name: Update HAF/TF-A Binaries External Dependency

on:
schedule:
# NOTE: If changing the schedule, CUTOFF_DATE in the `check` job must also be updated to match
- cron: '0 22 * * 6' # Every Saturday at 22:00 UTC
workflow_run:
workflows:
- Hafnium and Trusted Firmware-A Build
types:
- completed
workflow_dispatch: # Manual trigger

env:
Expand All @@ -23,6 +25,14 @@ jobs:
check:
name: Find New Releases

# For workflow_run events, only proceed when the build workflow succeeded and was triggered by a release.
# For workflow_dispatch, always proceed to allow manual runs.
if: |
github.event_name == 'workflow_dispatch' ||
(github.event_name == 'workflow_run' &&
github.event.workflow_run.conclusion == 'success' &&
github.event.workflow_run.event == 'release')

runs-on: ubuntu-latest

outputs:
Expand All @@ -35,7 +45,6 @@ jobs:
env:
REPO: ${{ env.REPO }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # We can use the normal token here, as we are just reading releases.
CUTOFF_DATE: $(date -d '7 days ago' --iso-8601=seconds)
EVENT_NAME: ${{ github.event_name }}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't look like EVENT_NAME is used anymore.

Suggested change
EVENT_NAME: ${{ github.event_name }}

shell: bash
run: |
Expand All @@ -55,15 +64,6 @@ jobs:
PUBLISHED_AT=$(echo "$RELEASE" | jq -r '.publishedAt // ""')

echo "Latest release: $TAG_NAME (published: $PUBLISHED_AT)"

# For scheduled runs, only use the release if it's within the cutoff date
if [[ "$EVENT_NAME" != "workflow_dispatch" && -n "$PUBLISHED_AT" ]]; then
if [[ "$PUBLISHED_AT" < "$CUTOFF_DATE" ]]; then
echo "Release $TAG_NAME is older than cutoff date, skipping."
TAG_NAME=""
fi
fi

echo "tag_name=$TAG_NAME" >> $GITHUB_OUTPUT

- name: Check if PR already exists
Expand Down
Loading