56 lines
2.1 KiB
YAML
56 lines
2.1 KiB
YAML
name: Test and deploy Factorio
|
|
on:
|
|
push:
|
|
pull_request:
|
|
concurrency:
|
|
group: factorio-${{ gitea.ref }}
|
|
cancel-in-progress: false
|
|
jobs:
|
|
validate:
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 20
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Install tools
|
|
run: |
|
|
python3 -m pip install --target "${RUNNER_TEMP}/python" 'PyYAML==6.0.3'
|
|
echo "PYTHONPATH=${RUNNER_TEMP}/python" >> "$GITHUB_ENV"
|
|
curl -fsSL https://dl.k8s.io/release/v1.35.3/bin/linux/amd64/kubectl -o /usr/local/bin/kubectl
|
|
chmod 0755 /usr/local/bin/kubectl
|
|
- name: Test policy and boot the actual game configuration
|
|
env:
|
|
FACTORIO_SMOKE_TEST: 'true'
|
|
run: ./test.sh
|
|
- name: Validate Kubernetes schemas
|
|
run: |
|
|
./render.sh | docker run --rm -i ghcr.io/yannh/kubeconform:v0.7.0 -strict -ignore-missing-schemas -summary
|
|
for file in namespace.yaml ci-deployer.yaml; do
|
|
printf '%s\n' '---'
|
|
cat "$file"
|
|
done | docker run --rm -i ghcr.io/yannh/kubeconform:v0.7.0 -strict -summary
|
|
deploy:
|
|
if: gitea.event_name == 'push' && gitea.ref == 'refs/heads/main'
|
|
needs: [validate]
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 35
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Install tools
|
|
run: |
|
|
python3 -m pip install --target "${RUNNER_TEMP}/python" 'PyYAML==6.0.3'
|
|
echo "PYTHONPATH=${RUNNER_TEMP}/python" >> "$GITHUB_ENV"
|
|
curl -fsSL https://dl.k8s.io/release/v1.35.3/bin/linux/amd64/kubectl -o /usr/local/bin/kubectl
|
|
chmod 0755 /usr/local/bin/kubectl
|
|
- name: Deploy using the dedicated Factorio service account
|
|
env:
|
|
KUBE_CONFIG_BASE64: ${{ secrets.KUBE_CONFIG_BASE64 }}
|
|
FACTORIO_CI: 'true'
|
|
run: |
|
|
set -eu
|
|
export KUBECONFIG="${RUNNER_TEMP}/factorio-kubeconfig"
|
|
trap 'rm -f "$KUBECONFIG"' EXIT
|
|
umask 077
|
|
printf '%s' "$KUBE_CONFIG_BASE64" | base64 -d > "$KUBECONFIG"
|
|
kubectl config set-cluster cluster --server=https://host.containers.internal:6443 --tls-server-name=192.168.0.2
|
|
./install.sh
|