Skip to content

Extract configs

Extract configs #80

name: "Extract configs"
on:
workflow_dispatch:
inputs:
paper_version:
description: 'Paper Minecraft version'
required: true
jobs:
generate-minecraft-configs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Pull itzg/minecraft-server image
run: docker pull itzg/minecraft-server
- name: Start Minecraft Server
run: |
docker run -d \
-e EULA=TRUE \
-e TYPE=PAPER \
-e VERSION=${{ github.event.inputs.paper_version }} \
-p 25565:25565 \
--name minecraft-server \
itzg/minecraft-server
- name: Wait for container to become healthy
run: |
while [[ "$(docker inspect -f '{{.State.Health.Status}}' minecraft-server)" != "healthy" ]]; do
if [[ "$(docker inspect -f '{{.State.Status}}' minecraft-server)" == "exited" ]]; then
echo "Container has stopped. Aborting workflow."
exit 1
fi
sleep 5
done
- name: Stop Minecraft Server
run: docker stop minecraft-server
- name: Copy configuration files
run: |
mkdir -p ${{ github.event.inputs.paper_version }}
docker cp -q minecraft-server:/data/config/paper-global.yml ./${{ github.event.inputs.paper_version }}/paper-global.yml || echo "not found, skipping"
docker cp -q minecraft-server:/data/config/paper-world-defaults.yml ./${{ github.event.inputs.paper_version }}/paper-world-defaults.yml || echo "not found, skipping"
docker cp -q minecraft-server:/data/spigot.yml ./${{ github.event.inputs.paper_version }}/spigot.yml || echo "not found, skipping"
docker cp -q minecraft-server:/data/paper.yml ./${{ github.event.inputs.paper_version }}/paper.yml || echo "not found, skipping"
- name: Commit configuration files
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 add ${{ github.event.inputs.paper_version }}
git commit -m "Add configuration files for Minecraft version ${{ github.event.inputs.paper_version }}"
git push origin HEAD:${{ github.event.inputs.paper_version }}
- name: Clear away Minecraft Server
run: docker rm minecraft-server