Update README from Template and Ensure necessary files are present #1
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
name: Update README from Template and Ensure necessary files are present | |
on: | |
workflow_dispatch: | |
inputs: | |
target_branch: | |
description: 'Branch to update in the target repository' | |
required: true | |
default: 'main' | |
jobs: | |
update-files: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout target repository | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.event.inputs.target_branch }} | |
- name: Set up Git | |
run: | | |
git config user.name "github-actions" | |
git config user.email "[email protected]" | |
- name: Clone template repository | |
run: | | |
git clone https://github.com/dockersamples/sample-app-template.git template-repo | |
- name: Ensure README.md, CONTRIBUTING.md, and LICENSE | |
run: | | |
# Update README.md | |
cp template-repo/README.md README.md | |
# Check if CONTRIBUTING.md exists, if not copy from template | |
if [ ! -f CONTRIBUTING.md ]; then | |
echo "CONTRIBUTING.md not found, adding it." | |
cp template-repo/CONTRIBUTING.md CONTRIBUTING.md | |
fi | |
# Check if LICENSE file exists, if not copy from template | |
if [ ! -f LICENSE ]; then | |
echo "LICENSE.md not found, adding it." | |
cp template-repo/LICENSE LICENSE | |
fi | |
- name: Commit and push changes | |
run: | | |
git add README.md CONTRIBUTING.md LICENSE | |
git commit -m "Update README.md and ensure CONTRIBUTING.md and LICENSE are present" || echo "No changes to commit" | |
git push origin ${{ github.event.inputs.target_branch }} | |
- name: Clean up | |
run: rm -rf template-repo |