Skip to content

Check for changes and commit every 12 hours #1394

Check for changes and commit every 12 hours

Check for changes and commit every 12 hours #1394

name: Check for changes and commit every 12 hours
on:
schedule:
- cron: 0 */12 * * *
workflow_dispatch:
jobs:
check_for_changes:
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: "actions/checkout@v3"
- name: Read current workflow env
id: get_current_env
uses: juliangruber/read-file-action@v1
with:
path: ./.env.workflow
trim: true
- name: Set current commit
id: set_commit_output
run: echo "::set-output name=current_commit::$(echo ${{ steps.get_current_env.outputs.content }} | cut -d'=' -f2)"
- name: Get latest TWIR commit
id: get_latest_commit
uses: octokit/request-action@v2.x
with:
route: GET /repos/{owner}/{repo}/commits
owner: rust-lang
repo: this-week-in-rust
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Control flow
id: control
run: echo "::set-output name=should_build::$([ ${{ steps.set_commit_output.outputs.current_commit }} "!=" ${{ fromJson(steps.get_latest_commit.outputs.data)[0].sha }} ] && echo true || echo false)"
- name: Make changes
if: ${{ steps.control.outputs.should_build == 'true' }}
run: |
touch .env.workflow
echo CURRENT_TWIR_COMMIT=${{ fromJson(steps.get_latest_commit.outputs.data)[0].sha }} > .env.workflow
git config --global user.name 'Dueen Eduarda'
git config --global user.email 'dueen@users.noreply.github.com'
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY
git commit -am "Detected changes in rust-lang/this-week-in-rust"
git push