diff --git a/.github/workflows/existing-repo.yaml b/.github/workflows/existing-repo.yaml new file mode 100644 index 0000000..44737a6 --- /dev/null +++ b/.github/workflows/existing-repo.yaml @@ -0,0 +1,54 @@ +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 "github-actions@github.com" + + - 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