update-video-id #1299
This file contains hidden or 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
| name: Update YouTube Video ID | |
| on: | |
| repository_dispatch: | |
| types: [update-video-id] | |
| workflow_dispatch: | |
| inputs: | |
| video_id: | |
| description: 'YouTube Video ID to update' | |
| required: true | |
| jobs: | |
| update-video-id: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Update video ID in HTML | |
| run: | | |
| sed -i "s/videoId: '[^']*'/videoId: '${{ github.event.client_payload.video_id || github.event.inputs.video_id }}'/" index.html | |
| env: | |
| VIDEO_ID: ${{ github.event.client_payload.video_id || github.event.inputs.video_id }} | |
| - name: Commit changes | |
| run: | | |
| git config --local user.email "action@github.com" | |
| git config --local user.name "GitHub Action" | |
| git add index.html | |
| git commit -m "Update YouTube video ID to ${{ github.event.client_payload.video_id || github.event.inputs.video_id }}" || echo "No changes to commit" | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Pull latest changes | |
| run: | | |
| git pull --rebase origin main | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Push changes | |
| run: | | |
| git push origin main | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |