-
Notifications
You must be signed in to change notification settings - Fork 0
49 lines (41 loc) · 1.67 KB
/
init-setup.yml
File metadata and controls
49 lines (41 loc) · 1.67 KB
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
name: Initial Setup
on:
push:
jobs:
initial_setup:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Ensure single commit in repository
run: |
# Count the total number of commits
COMMIT_COUNT=$(git rev-list --count HEAD)
# Stop the workflow if the commit count is greater than 1
if [ "$COMMIT_COUNT" -gt 2 ]; then
echo "The repository has more than 2 commit ($COMMIT_COUNT commits). Stopping workflow."
exit 1
else
echo "The repository has $COMMIT_COUNT commit(s). Proceeding with the workflow."
fi
- name: Rename Container Name
run: |
# Extract the repository name from GITHUB_REPOSITORY
REPO_NAME=$(echo "${GITHUB_REPOSITORY##*/}")
# Replace {REPO_NAME} in docker-compose.yml
sed -i "s/{REPO_NAME}/${REPO_NAME}/g" .devcontainer/docker-compose.yml
- name: Remove initial setup workflow
run: rm -rf .github
continue-on-error: true
- name: Commit and push changes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
git add -A
git commit -m "Rename .devcontainer/docker and remove first-run workflow after initialization"
git push