Skip to content

chore: update GitHub Action #2

chore: update GitHub Action

chore: update GitHub Action #2

name: Update Last Modified Date
on:
push:
branches:
- blog
workflow_dispatch:
jobs:
updateLastModified:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.3'
- name: Install dependencies
run: bundle install
- name: Update last_modified_at field
run: |
posts_dir="_posts"
for post_path in $(find "$posts_dir" -name "*.md"); do
commit_count=$(git rev-list --count HEAD "$post_path")
last_modified=$(git log -1 --pretty="%ad" --date=format:'%Y-%m-%d %H:%M %z' "$post_path" | xargs)
content=$(cat "$post_path")
if [[ "$content" =~ ^date:\ (.+) ]]; then
if [[ "$content" =~ ^last_modified_at: ]]; then
sed -i "s/^last_modified_at:.*/last_modified_at: $last_modified/" "$post_path"
elif [[ $commit_count -gt 1 ]]; then
sed -i "/^date: /a last_modified_at: $last_modified" "$post_path"
fi
fi
done
- name: Commit changes
run: |
git config --global user.name "GitHub Action"
git config --global user.email "[email protected]"
git add _posts/*.md
git commit -m "Update last_modified_at field in posts" || echo "No changes to commit"
deployToCloudflare:
runs-on: ubuntu-latest
needs: updateLastModified # Ensure this runs after the updateLastModified job
steps:
- name: Push changes
run: git push origin blog
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:

Check failure on line 58 in .github/workflows/update_last_modified.yml

View workflow run for this annotation

GitHub Actions / Update Last Modified Date

Invalid workflow file

The workflow is not valid. .github/workflows/update_last_modified.yml (Line: 58, Col: 9): Unexpected value 'with'
apiToken: ${{ secrets.CF_API_TOKEN }}
accountId: ${{ secrets.CF_ACCOUNT_ID }}
projectName: "stevehoang"
directory: "_site"