-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
78 additions
and
0 deletions.
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,51 @@ | ||
name: Update latest issues | ||
|
||
on: | ||
schedule: | ||
- cron: '0 12 * * *' # every day at noon | ||
workflow_dispatch: {} | ||
|
||
jobs: | ||
update-latest-issues: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3.5.3 | ||
- name: update issues | ||
id: updateIssues | ||
run: bash ./script-for-using-latest-version.sh | ||
- uses: pCYSl5EDgo/cat@master | ||
id: read_recent | ||
with: | ||
path: ./issues.txt | ||
- run: | | ||
echo "ISSUE_NUMBER=${{ steps.read_recent.outputs.text }}" >> $GITHUB_ENV | ||
- name: config git | ||
run: | | ||
git config --local user.email "1439809+joergi@users.noreply.github.com" | ||
git config --local user.name "Joergi via GitHub Actions" | ||
- name: Create Pull Request | ||
id: createAutoPR | ||
uses: peter-evans/create-pull-request@v5 | ||
with: | ||
title: new Issue ${{ env.ISSUE_NUMBER }} - Automated PR | ||
commit-message: new Issue ${{ env.ISSUE_NUMBER }} - Automated PR | ||
token: ${{ secrets.MY_GITHUB_TOKEN }} | ||
body: Automated pull request for issue ${{ env.ISSUE_NUMBER }} created by GitHub Actions | ||
branch: automated_PR_for_update_issues | ||
branch-suffix: timestamp | ||
base: main | ||
delete-branch: true | ||
labels: "automerge" | ||
- name: Auto approve | ||
id: autoApprove | ||
if: steps.createAutoPR.outputs.pull-request-operation == 'created' | ||
uses: juliangruber/approve-pull-request-action@v2 | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
number: ${{ steps.createAutoPR.outputs.pull-request-number }} | ||
- name: Enable Pull Request Automerge | ||
if: steps.createAutoPR.outputs.pull-request-operation == 'created' | ||
uses: peter-evans/enable-pull-request-automerge@v2 | ||
with: | ||
token: ${{ secrets.MY_GITHUB_TOKEN }} | ||
pull-request-number: ${{ steps.createAutoPR.outputs.pull-request-number }} |
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,27 @@ | ||
#!/bin/bash | ||
set -o errexit | ||
#set -o pipefail | ||
set -o nounset | ||
IFS=$'\n\t' | ||
|
||
# ------------------------------------------------------------------ | ||
# based on the script Kenichi Nagai https://github.com/keni-n/ | ||
# https://github.com/joergi/MagPiDownloader/blob/main/linux_mac/magpi-issue-downloader-latest.sh | ||
# ------------------------------------------------------------------ | ||
|
||
# VERSION=0.1 | ||
# you don't need to run this script | ||
# this is running automatically on Github each day to update the latest issues | ||
|
||
TARGET_URL="https://helloworldraspberrypi.com/" | ||
BASEDIR=$(dirname "$0") | ||
|
||
#printf -v page_url "$TARGET_URL/issues" | ||
page_url=$(printf '%s\n' "$TARGET_URL/issues") | ||
|
||
latest_issue=$(curl -sf "$page_url" | grep "Get PDF" | head -n 1 | sed 's/^.*issues\///' | sed 's/\/pdf.*$//') | ||
echo "Latest Issue is " "$latest_issue" | ||
|
||
file="$BASEDIR/regular-issues.txt"; | ||
echo $file | ||
echo "$latest_issue" >"$file" |