generated from wuespace/telestion-project-template
-
Notifications
You must be signed in to change notification settings - Fork 0
77 lines (67 loc) · 2.48 KB
/
initialize.yml
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
name: Initialize
# Events that trigger this workflow
on:
workflow_dispatch:
inputs:
group:
description: "Gradle Group Name"
required: true
default: "de.wuespace.telestion.project.template"
jobs:
initialize:
name: Initialize the project
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/[email protected]
- name: Setup environment
run: |
echo "repo_name=$(echo "$GITHUB_REPOSITORY" | cut -d "/" -f 2 -)" >> $GITHUB_ENV
echo "repo_user=$(echo "$GITHUB_REPOSITORY" | cut -d "/" -f 1 -)" >> $GITHUB_ENV
echo "lock_file=${GITHUB_WORKSPACE}/.github/initialized" >> $GITHUB_ENV
- name: Check initialization state
run: |
test ! -f "$LOCK_FILE"
env:
LOCK_FILE: ${{ env.lock_file }}
- name: Update settings.gradle
run: |
sed -i "s/${PLACEHOLDER}/${REPLACE_WITH}/g" "$FILE"
env:
PLACEHOLDER: "##REPO_NAME##"
REPLACE_WITH: ${{ env.repo_name }}
FILE: "${{ github.workspace }}/application/settings.gradle"
- name: Update Dockerfile
run: |
sed -i "s/${PLACEHOLDER}/${REPLACE_WITH}/g" "$FILE"
env:
PLACEHOLDER: "##REPO_NAME##"
REPLACE_WITH: ${{ env.repo_name }}
FILE: "${{ github.workspace }}/application/Dockerfile"
- name: Update build.gradle
run: |
sed -i "s/${PLACEHOLDER}/${REPLACE_WITH}/g" "$FILE"
env:
PLACEHOLDER: "##GROUP_ID##"
REPLACE_WITH: ${{ github.event.inputs.group }}
FILE: "${{ github.workspace }}/application/build.gradle"
- name: Generate folder structure
run: |
FOLDERS="$(echo "$GROUP" | sed -e 's/\./\//g')"
mkdir -p "${JAVA_MAIN_SRC}/${FOLDERS}"
touch "${JAVA_MAIN_SRC}/${FOLDERS}/.gitkeep"
env:
GROUP: ${{ github.event.inputs.group }}
JAVA_MAIN_SRC: "${{ github.workspace }}/application/src/main/java"
- name: Initialization finished. Locking action...
run: |
echo "This project was initialized with Github Actions" > "$LOCK_FILE"
env:
LOCK_FILE: ${{ env.lock_file }}
- name: Pushing changes to remote
run: |
git config --local user.name "${GITHUB_ACTOR}"
git config --local user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git add .
git commit -m "feat: Initialize project"
git push