Skip to content

Commit

Permalink
Merge pull request #525 from CivMC/main
Browse files Browse the repository at this point in the history
Update branch
  • Loading branch information
RedDevel2 committed May 12, 2024
2 parents 068ac6e + 2f5c880 commit ef344b8
Show file tree
Hide file tree
Showing 160 changed files with 7,463 additions and 147 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/ansible_kira_restart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,19 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: ☕ Setup Java
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'

- name: 🐘 Setup Gradle
uses: gradle/actions/setup-gradle@v3

- name: 🐘 Gradle Build
run: CI=true ./gradlew :ansible:build

- name: Inject secrets
run: 'echo "$SECRETS_YML" > variables/secrets.yml'
shell: bash
Expand Down
13 changes: 13 additions & 0 deletions .github/workflows/ansible_ping.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,19 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: ☕ Setup Java
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'

- name: 🐘 Setup Gradle
uses: gradle/actions/setup-gradle@v3

- name: 🐘 Gradle Build
run: CI=true ./gradlew :ansible:build

- name: Inject secrets
run: 'echo "$SECRETS_YML" > variables/secrets.yml'
shell: bash
Expand Down
13 changes: 13 additions & 0 deletions .github/workflows/ansible_setup_server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,19 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: ☕ Setup Java
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'

- name: 🐘 Setup Gradle
uses: gradle/actions/setup-gradle@v3

- name: 🐘 Gradle Build
run: CI=true ./gradlew :ansible:build

- name: Inject secrets
run: 'echo "$SECRETS_YML" > variables/secrets.yml'
shell: bash
Expand Down
13 changes: 13 additions & 0 deletions .github/workflows/ansible_start_server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,19 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: ☕ Setup Java
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'

- name: 🐘 Setup Gradle
uses: gradle/actions/setup-gradle@v3

- name: 🐘 Gradle Build
run: CI=true ./gradlew :ansible:build

- name: Inject secrets
run: 'echo "$SECRETS_YML" > variables/secrets.yml'
shell: bash
Expand Down
13 changes: 13 additions & 0 deletions .github/workflows/ansible_stop_server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,19 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: ☕ Setup Java
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'

- name: 🐘 Setup Gradle
uses: gradle/actions/setup-gradle@v3

- name: 🐘 Gradle Build
run: CI=true ./gradlew :ansible:build

- name: Inject secrets
run: 'echo "$SECRETS_YML" > variables/secrets.yml'
shell: bash
Expand Down
13 changes: 13 additions & 0 deletions .github/workflows/ansible_update_server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,19 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: ☕ Setup Java
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'

- name: 🐘 Setup Gradle
uses: gradle/actions/setup-gradle@v3

- name: 🐘 Gradle Build
run: CI=true ./gradlew :ansible:build

- name: Inject secrets
run: 'echo "$SECRETS_YML" > variables/secrets.yml'
shell: bash
Expand Down
12 changes: 4 additions & 8 deletions .github/workflows/build_gradle_project.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,17 @@ jobs:
- name: 🚩 Checkout Repo
uses: actions/checkout@v4

- name: ❓ Ensure Wrapper Permissions
run: chmod +x ./gradlew

- name: ☕ Setup Java
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'

- name: 🐘 Setup Gradle
uses: gradle/actions/setup-gradle@v3

- name: 🐘 Gradle Build
uses: gradle/gradle-build-action@v2
env:
CI: true
with:
arguments: "${{inputs.category}}:${{inputs.project}}:build --scan"
run: CI=true ./gradlew ${{inputs.category}}:${{inputs.project}}:build --scan

- name: 🗃️ Upload Build Artifact
uses: actions/upload-artifact@v3
Expand Down
12 changes: 4 additions & 8 deletions .github/workflows/check_gradle_all.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,14 @@ jobs:
- name: 🚩 Checkout Repo
uses: actions/checkout@v4

- name: ❓ Ensure Wrapper Permissions
run: chmod +x ./gradlew

- name: ☕ Setup Java
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'

- name: 🐘 Setup Gradle
uses: gradle/actions/setup-gradle@v3

- name: 🐘 Gradle Check
uses: gradle/gradle-build-action@v2
env:
CI: true
with:
arguments: "check --scan"
run: CI=true ./gradlew check --scan
21 changes: 6 additions & 15 deletions .github/workflows/publish_gradle_project.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,23 +48,19 @@ jobs:
- name: 🚩 Checkout Repo
uses: actions/checkout@v4

- name: ❓ Ensure Wrapper Permissions
run: chmod +x ./gradlew

- name: ☕ Setup Java
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'

# TODO: Bump version if not already done
- name: 🐘 Setup Gradle
uses: gradle/actions/setup-gradle@v3

# TODO: Bump version if not already done

- name: 🐘 Gradle Build
uses: gradle/gradle-build-action@v2
env:
CI: true
with:
arguments: "${{needs.determine_values.outputs.category}}:${{needs.determine_values.outputs.project}}:build --scan"
run: CI=true ./gradlew ${{needs.determine_values.outputs.category}}:${{needs.determine_values.outputs.project}}:build --scan

- name: 🗃️ Create/Update Release
uses: softprops/action-gh-release@v1
Expand All @@ -73,9 +69,4 @@ jobs:
files: '${{needs.determine_values.outputs.category}}/${{needs.determine_values.outputs.project}}/build/libs/*'

- name: 🐘 Gradle Publish
uses: gradle/gradle-build-action@v2
env:
CI: true
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
arguments: "${{needs.determine_values.outputs.category}}:${{needs.determine_values.outputs.project}}:publish --scan"
run: CI=true GITHUB_TOKEN=${{secrets.GITHUB_TOKEN}} ./gradlew ${{needs.determine_values.outputs.category}}:${{needs.determine_values.outputs.project}}:publish --scan
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@ This monorepo will eventually contain all civ projects and development

### Containers
A docker compose stack is provided to help test containers built from
this repo. To start the stack, run the following command:
`docker compose up --build`. Please note that this stack is NOT suitable for production use.
this repo. To start the stack, run the following commands:

1. `gradle :ansible:build`
2. `docker compose up`

Please note that this stack is NOT suitable for production use.

Container data (world, logs, etc.) are mounted at [./containers/data](./containers/data).

Expand Down
8 changes: 8 additions & 0 deletions ansible/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# CivAnsible
This project is a hybrid gradle/ansible project that is designed to provision and deploy services to a server.

Vendored plugins are located in `src/` (gradle), since they are used to build the end plugin directory (`/build/`)
Configs are located in `files/`, since they are purely copied by ansible

## Prerequisites
1. Create a user on the server named `actions` with sudo privileges
Expand All @@ -9,6 +13,10 @@
3. Create a repo scoped secret with the contents of your secrets.yml called SECRETS_YML
4. Create an ansible inventory named after the environment

## Usage
1. Build dependencies with `gradle :ansible:build`
2. Use an ansible playbook with `ansible-playbook -i inventories/<inventory> playbooks/<playbook>`

## TODOs
- Private Config
- Mount backups location and configure params, setup
Expand Down
50 changes: 50 additions & 0 deletions ansible/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
val paperPlugin by configurations.creating
val proxyPlugin by configurations.creating

dependencies {
paperPlugin(project(path = ":plugins:banstick-paper", configuration = "reobf"))
paperPlugin(project(path = ":plugins:bastion-paper", configuration = "reobf"))
paperPlugin(project(path = ":plugins:castlegates-paper", configuration = "reobf"))
paperPlugin(project(path = ":plugins:citadel-paper", configuration = "reobf"))
paperPlugin(project(path = ":plugins:civchat2-paper", configuration = "reobf"))
paperPlugin(project(path = ":plugins:civduties-paper", configuration = "reobf"))
paperPlugin(project(path = ":plugins:civmodcore-paper", configuration = "reobf"))
paperPlugin(project(path = ":plugins:combattagplus-paper", configuration = "reobf"))
paperPlugin(project(path = ":plugins:donum-paper"))
paperPlugin(project(path = ":plugins:essenceglue-paper", configuration = "reobf"))
paperPlugin(project(path = ":plugins:exilepearl-paper", configuration = "reobf"))
paperPlugin(project(path = ":plugins:factorymod-paper", configuration = "reobf"))
paperPlugin(project(path = ":plugins:finale-paper", configuration = "reobf"))
paperPlugin(project(path = ":plugins:hiddenore-paper", configuration = "reobf"))
paperPlugin(project(path = ":plugins:itemexchange-paper", configuration = "reobf"))
paperPlugin(project(path = ":plugins:jukealert-paper", configuration = "reobf"))
paperPlugin(project(path = ":plugins:kirabukkitgateway-paper", configuration = "reobf"))
paperPlugin(project(path = ":plugins:namecolors-paper", configuration = "reobf"))
paperPlugin(project(path = ":plugins:namelayer-paper", configuration = "reobf"))
paperPlugin(project(path = ":plugins:railswitch-paper", configuration = "reobf"))
paperPlugin(project(path = ":plugins:randomspawn-paper", configuration = "reobf"))
paperPlugin(project(path = ":plugins:realisticbiomes-paper", configuration = "reobf"))
paperPlugin(project(path = ":plugins:simpleadminhacks-paper", configuration = "reobf"))
}

val copyPaperPlugins = tasks.register<Copy>("copyPaperPlugins") {
dependsOn(paperPlugin)

from("$projectDir/src/paper-plugins")
from(paperPlugin.resolvedConfiguration.resolvedArtifacts.map { it.file })
into("$buildDir/paper-plugins")
}

val copyProxyPlugins = tasks.register<Copy>("copyProxyPlugins") {
dependsOn(proxyPlugin)

from("$projectDir/src/proxy-plugins")
from(proxyPlugin.resolvedConfiguration.resolvedArtifacts.map { it.file })
into("$buildDir/proxy-plugins")
}

// TODO: Is build the right name?
tasks.register("build") {
dependsOn(copyPaperPlugins)
dependsOn(copyProxyPlugins)
}
Binary file not shown.
Binary file not shown.
Binary file removed ansible/files/paper-plugins/bastion-paper-3.0.1.jar
Binary file not shown.
Binary file not shown.
Binary file removed ansible/files/paper-plugins/citadel-paper-5.2.4.jar
Binary file not shown.
Binary file removed ansible/files/paper-plugins/civchat2-paper-2.2.2.jar
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed ansible/files/paper-plugins/finale-paper-2.1.0.jar
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
3 changes: 3 additions & 0 deletions ansible/playbooks/ping.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
hosts: all

tasks:
- name: Ping | Include Preflight
include_tasks: ../tasks/preflight-checks.yml

- name: Configure | Expand setting
include_tasks: ../tasks/expand-setting.yml

Expand Down
3 changes: 3 additions & 0 deletions ansible/playbooks/restart-kira.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
become: true

tasks:
- name: Restart Kira | Include Preflight
include_tasks: ../tasks/preflight-checks.yml

- name: Restart Kira | Expand setting
include_tasks: ../tasks/expand-setting.yml

Expand Down
3 changes: 3 additions & 0 deletions ansible/playbooks/setup-server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
become: true

tasks:
- name: Setup Server | Include Preflight
include_tasks: ../tasks/preflight-checks.yml

- name: Setup Server | Expand setting
include_tasks: ../tasks/expand-setting.yml

Expand Down
3 changes: 3 additions & 0 deletions ansible/playbooks/start-server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
become: true

tasks:
- name: Start Server | Include Preflight
include_tasks: ../tasks/preflight-checks.yml

- name: Start Server | Expand setting
include_tasks: ../tasks/expand-setting.yml

Expand Down
3 changes: 3 additions & 0 deletions ansible/playbooks/stop-server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
become: true

tasks:
- name: Stop Server| Include Preflight
include_tasks: ../tasks/preflight-checks.yml

- name: Stop Server | Expand setting
include_tasks: ../tasks/expand-setting.yml

Expand Down
3 changes: 3 additions & 0 deletions ansible/playbooks/update-server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
become: true

tasks:
- name: Update Serer | Include Preflight
include_tasks: ../tasks/preflight-checks.yml

- name: Update Server | Expand setting
include_tasks: ../tasks/expand-setting.yml

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 5 additions & 5 deletions ansible/tasks/deploy/stacks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@
- "'swarm_manager' in group_names"
- item.enabled
copy:
src: '../../files/{{item.file}}'
src: '{{item.file}}'
dest: '/opt/stacks/{{item.target}}'
loop:
- { file: 'paper-config', target: 'minecraft', enabled: setting.minecraft.enabled }
- { file: 'paper-plugins', target: 'minecraft', enabled: setting.minecraft.enabled }
- { file: 'proxy-config', target: 'minecraft', enabled: setting.minecraft.enabled }
- { file: 'proxy-plugins', target: 'minecraft', enabled: setting.minecraft.enabled }
- { file: '../../files/paper-config', target: 'minecraft', enabled: setting.minecraft.enabled }
- { file: '../../files/proxy-config', target: 'minecraft', enabled: setting.minecraft.enabled }
- { file: '../../build/paper-plugins', target: 'minecraft', enabled: setting.minecraft.enabled }
- { file: '../../build/proxy-plugins', target: 'minecraft', enabled: setting.minecraft.enabled }

- name: Deploy Stacks | Deploy Stacks
when:
Expand Down
19 changes: 19 additions & 0 deletions ansible/tasks/preflight-checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
- name: Preflight Checks | Check for secrets.yml
connection: local
stat: path=../variables/secrets.yml
register: secrets_yml

- name: Preflight Checks | Fail if secrets.yml is missing
fail:
msg: "secrets.yml is missing, please create it by copying variables/secrets.example.yml"
when: not secrets_yml.stat.exists

- name: Preflight Checks | Check for build dir
connection: local
stat: path=../build/
register: build_dir

- name: Preflight Checks | Fail if build dir is missing
fail:
msg: "build/ is missing, please create it by running `gradle :ansible:build`"
when: not build_dir.stat.exists
Loading

0 comments on commit ef344b8

Please sign in to comment.