-
Notifications
You must be signed in to change notification settings - Fork 733
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Auto update h5p #12806
Merged
Merged
Auto update h5p #12806
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
name: Update H5P JS library | ||
|
||
on: | ||
schedule: | ||
# Runs at 00:00 UTC on Wednesday | ||
- cron: '0 0 * * 3' | ||
# Optional: Allow manual triggering | ||
workflow_dispatch: | ||
|
||
jobs: | ||
check-commits: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: 'develop' | ||
fetch-depth: 0 | ||
persist-credentials: false | ||
|
||
- name: Get latest commit from target repo | ||
id: get-commit | ||
uses: octokit/[email protected] | ||
with: | ||
route: GET /repos/{owner}/{repo}/branches/{branch} | ||
owner: h5p | ||
repo: h5p-php-library | ||
branch: master | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Check commit status | ||
id: check-commit | ||
run: | | ||
import os | ||
from pathlib import Path | ||
# Get the latest commit from the API response | ||
latest_commit = "${{ fromJson(steps.get-commit.outputs.data).commit.sha }}".strip() | ||
# Check stored commit | ||
commit_file = Path('packages/hashi/.h5p-commit-sha') | ||
stored_commit = "" | ||
if commit_file.exists(): | ||
stored_commit = commit_file.read_text().strip() | ||
has_changed = stored_commit != latest_commit | ||
else: | ||
print("No stored commit found, treating as new") | ||
has_changed = True | ||
# Set outputs for GitHub Actions | ||
with open(os.environ['GITHUB_OUTPUT'], 'a') as f: | ||
print(f"stored_commit={stored_commit}", file=f) | ||
print(f"latest_commit={latest_commit}", file=f) | ||
print(f"changed={'true' if has_changed else 'false'}", file=f) | ||
shell: python | ||
|
||
- name: Use Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: '18.x' | ||
- name: Get yarn cache directory path | ||
id: yarn-cache-dir-path | ||
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT | ||
- name: Cache Node.js modules | ||
uses: actions/cache@v4 | ||
with: | ||
path: ${{ steps.yarn-cache-dir-path.outputs.dir }} | ||
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-yarn- | ||
|
||
- name: Update commit file and run script | ||
if: steps.check-commit.outputs.changed == 'true' | ||
run: | | ||
# Update the commit file | ||
echo "${{ steps.check-commit.outputs.latest_commit }}" > packages/hashi/.h5p-commit-sha | ||
|
||
# Run your script here | ||
yarn workspace hashi run build-h5p | ||
|
||
- name: Generate App Token | ||
if: steps.check-commit.outputs.changed == 'true' | ||
id: generate-token | ||
uses: tibdex/github-app-token@v2 | ||
with: | ||
app_id: ${{ secrets.LE_BOT_APP_ID }} | ||
private_key: ${{ secrets.LE_BOT_PRIVATE_KEY }} | ||
|
||
- name: Create Pull Request | ||
if: steps.check-commit.outputs.changed == 'true' | ||
uses: peter-evans/create-pull-request@v6 | ||
with: | ||
token: ${{ steps.generate-token.outputs.token }} | ||
commit-message: | | ||
Update commit SHA and run script | ||
|
||
Target repo commit: ${{ steps.check-commit.outputs.latest_commit }} | ||
branch: h5p_update | ||
delete-branch: true | ||
title: 'Update from target repository commit' | ||
body: | | ||
This PR was automatically created by the Update H5P JS library Github Action. | ||
Updates from target repository commit: ${{ steps.check-commit.outputs.latest_commit }} | ||
https://github.com/h5p/h5p-php-library/compare/${{ steps.check-commit.outputs.stored_commit }}...${{ steps.check-commit.outputs.latest_commit }} | ||
base: develop |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love all of this injected Python stuff, but this in particular is really neat to write to the env var as a file to speak to the GH action runner.