-
Notifications
You must be signed in to change notification settings - Fork 5
54 lines (44 loc) · 1.62 KB
/
existing-repo.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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 "[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