|
| 1 | +name: Update README from Template and Ensure necessary files are present |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + target_branch: |
| 7 | + description: 'Branch to update in the target repository' |
| 8 | + required: true |
| 9 | + default: 'main' |
| 10 | + |
| 11 | +jobs: |
| 12 | + update-files: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + |
| 15 | + steps: |
| 16 | + - name: Checkout target repository |
| 17 | + uses: actions/checkout@v3 |
| 18 | + with: |
| 19 | + ref: ${{ github.event.inputs.target_branch }} |
| 20 | + |
| 21 | + - name: Set up Git |
| 22 | + run: | |
| 23 | + git config user.name "github-actions" |
| 24 | + git config user.email "[email protected]" |
| 25 | +
|
| 26 | + - name: Clone template repository |
| 27 | + run: | |
| 28 | + git clone https://github.com/dockersamples/sample-app-template.git template-repo |
| 29 | +
|
| 30 | + - name: Ensure README.md, CONTRIBUTING.md, and LICENSE |
| 31 | + run: | |
| 32 | + # Update README.md |
| 33 | + cp template-repo/README.md README.md |
| 34 | +
|
| 35 | + # Check if CONTRIBUTING.md exists, if not copy from template |
| 36 | + if [ ! -f CONTRIBUTING.md ]; then |
| 37 | + echo "CONTRIBUTING.md not found, adding it." |
| 38 | + cp template-repo/CONTRIBUTING.md CONTRIBUTING.md |
| 39 | + fi |
| 40 | +
|
| 41 | + # Check if LICENSE file exists, if not copy from template |
| 42 | + if [ ! -f LICENSE ]; then |
| 43 | + echo "LICENSE.md not found, adding it." |
| 44 | + cp template-repo/LICENSE LICENSE |
| 45 | + fi |
| 46 | +
|
| 47 | + - name: Commit and push changes |
| 48 | + run: | |
| 49 | + git add README.md CONTRIBUTING.md LICENSE |
| 50 | + git commit -m "Update README.md and ensure CONTRIBUTING.md and LICENSE are present" || echo "No changes to commit" |
| 51 | + git push origin ${{ github.event.inputs.target_branch }} |
| 52 | +
|
| 53 | + - name: Clean up |
| 54 | + run: rm -rf template-repo |
0 commit comments