Skip to content

.github/workflows/check-status.yml #51

.github/workflows/check-status.yml

.github/workflows/check-status.yml #51

Workflow file for this run

name: Check VM Status
on:
workflow_dispatch:
schedule:
- cron: '*/30 * * * *'
jobs:
check-vm:
runs-on: ubuntu-latest
steps:
- name: Check Status File
id: check
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.VM_HOST }}
username: ${{ secrets.VM_USER }}
key: ${{ secrets.VM_SSH_KEY }}
script: |
cat ~/test-actions/status.json
- name: Checkout code
uses: actions/checkout@v2
with:
ref: master # Specify the branch
fetch-depth: 0 # Fetch all history
- name: Update README
run: |
# Configure git
git config --global user.name 'GitHub Action'
git config --global user.email '[email protected]'
# Pull latest changes
git pull origin master
# Update README content
if grep -q "## Status" README.md; then
# If status section exists, update it
sed -i '/## Status/,/^$/c\## Status\n![Status](https://img.shields.io/badge/status-ready-green)\n' README.md
else
# If no status section, add it at the top
echo -e "## Status\n![Status](https://img.shields.io/badge/status-ready-green)\n\n$(cat README.md)" > README.md.tmp
mv README.md.tmp README.md
fi
# Commit and push if there are changes
git add README.md
if git diff --staged --quiet; then
echo "No changes to commit"
else
git commit -m "Update status badge [skip ci]"
git push origin master
fi