Skip to content

Commit

Permalink
fix ci (#115)
Browse files Browse the repository at this point in the history
* fix ci

* fix hetzner image deploy

* remove temporal ci trigger
  • Loading branch information
dhenkel92 authored May 4, 2024
1 parent c7eb161 commit 2d4384e
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 87 deletions.
5 changes: 0 additions & 5 deletions .github/scripts/auth.sh

This file was deleted.

34 changes: 18 additions & 16 deletions .github/workflows/base-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ on:
branches:
- main
paths:
- '.github/workflows/base-image.yml'
- 'infrastructure/packer/**/*'
- 'infrastructure/ansible/**/*'
- ".github/workflows/base-image.yml"
- "infrastructure/packer/**/*"
- "infrastructure/ansible/**/*"

name: Base Image

Expand All @@ -16,23 +16,25 @@ jobs:
steps:
- name: Checkout Repository
uses: actions/checkout@v2
# fix backwards incompatibilities in template
- name: Fix Template
uses: hashicorp/packer-github-actions@master
- name: Setup `packer`
uses: hashicorp/setup-packer@main
id: setup
with:
command: fix
target: infrastructure/packer/manifests/basic_gameserver.json
# validate templates
- name: Validate Template
uses: hashicorp/packer-github-actions@master
with:
command: validate
arguments: -syntax-only
target: infrastructure/packer/manifests/basic_gameserver.json
version: v1.10.3
- name: Run `packer init`
id: init
working-directory: infrastructure/packer/
run: "packer init ./manifests/basic_gameserver.pkr.hcl"
- name: Run `packer validate`
id: validate
working-directory: infrastructure/packer/
run: "packer validate ./manifests/basic_gameserver.pkr.hcl"
env:
HCLOUD_TOKEN: ${{ secrets.HCLOUD_TOKEN }}
# build artifact
- name: Build Packer image
working-directory: infrastructure/packer/
run: packer build -color=false -on-error=abort -var-file ./vars/production.json ./manifests/basic_gameserver.json
run: packer build -color=false -on-error=abort -var-file ./vars/production.hcl ./manifests/basic_gameserver.pkr.hcl
env:
PACKER_LOG: 1h
HCLOUD_TOKEN: ${{ secrets.HCLOUD_TOKEN }}
33 changes: 15 additions & 18 deletions .github/workflows/consumer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ on:
branches:
- main
paths:
- '.github/workflows/consumer.yml'
- '.github/scripts/auth.sh'
- '.github/scripts/deploy.sh'
- 'async-server-provisioner/*'
- 'async-server-provisioner/*/*'
- 'async-server-provisioner/*/*/*'
- 'async-server-provisioner/*/*/*/*'
- 'async-server-provisioner/*/*/*/*/*'
- 'infrastructure/terraform/02-game-server/**/*'
- ".github/workflows/consumer.yml"
- ".github/scripts/auth.sh"
- ".github/scripts/deploy.sh"
- "async-server-provisioner/*"
- "async-server-provisioner/*/*"
- "async-server-provisioner/*/*/*"
- "async-server-provisioner/*/*/*/*"
- "async-server-provisioner/*/*/*/*/*"
- "infrastructure/terraform/02-game-server/**/*"

name: Cloud Game Consumer

Expand All @@ -20,17 +20,14 @@ jobs:
name: Build Consumer
runs-on: ubuntu-latest
env:
IMAGE: 220002198733.dkr.ecr.eu-central-1.amazonaws.com/cloud-game/consumer
IMAGE: cloudgame/async-server-provisioner
steps:
- uses: actions/checkout@master
- name: Authenticate
# if: github.ref == 'refs/heads/main'
run: ./.github/scripts/auth.sh
env:
AWS_ACCESS_KEY_ID: ${{ secrets.ECR_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.ECR_AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: eu-central-1
ECR_ACCOUNT: 220002198733.dkr.ecr.eu-central-1.amazonaws.com
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build Docker Container
run: |
docker build -t $IMAGE:$GITHUB_RUN_ID -f async-server-provisioner/Dockerfile .
Expand Down
30 changes: 14 additions & 16 deletions .github/workflows/react-frontend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ on:
branches:
- main
paths:
- '.github/workflows/react-frontend.yml'
- '.github/scripts/auth.sh'
- '.github/scripts/deploy.sh'
- 'react-frontend/*'
- 'react-frontend/*/*'
- 'react-frontend/*/*/*'
- 'react-frontend/*/*/*/*'
- 'react-frontend/*/*/*/*/*'
- ".github/workflows/react-frontend.yml"
- ".github/scripts/auth.sh"
- ".github/scripts/deploy.sh"
- "react-frontend/*"
- "react-frontend/*/*"
- "react-frontend/*/*/*"
- "react-frontend/*/*/*/*"
- "react-frontend/*/*/*/*/*"

name: Cloud Game React Frontend

Expand All @@ -19,16 +19,14 @@ jobs:
name: Build React Frontend
runs-on: ubuntu-latest
env:
IMAGE: 220002198733.dkr.ecr.eu-central-1.amazonaws.com/cloud-game/react/frontend
IMAGE: cloudgame/frontend
steps:
- uses: actions/checkout@master
- name: Authenticate
run: ./.github/scripts/auth.sh
env:
AWS_ACCESS_KEY_ID: ${{ secrets.ECR_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.ECR_AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: eu-central-1
ECR_ACCOUNT: 220002198733.dkr.ecr.eu-central-1.amazonaws.com
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build Docker Container
run: |
cd react-frontend
Expand Down
40 changes: 17 additions & 23 deletions .github/workflows/strapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ on:
branches:
- main
paths:
- '.github/workflows/strapi.yml'
- '.github/scripts/auth.sh'
- '.github/scripts/deploy.sh'
- 'backend/**/*'
- ".github/workflows/strapi.yml"
- ".github/scripts/auth.sh"
- ".github/scripts/deploy.sh"
- "backend/**/*"

name: Cloud Game Backend Strapi

Expand All @@ -15,17 +15,14 @@ jobs:
name: Build Strapi API
runs-on: ubuntu-latest
env:
IMAGE: 220002198733.dkr.ecr.eu-central-1.amazonaws.com/cloud-game/strapi/backend
IMAGE: cloudgame/backend-api
steps:
- uses: actions/checkout@master
- name: Authenticate
# if: github.ref == 'refs/heads/main'
run: ./.github/scripts/auth.sh
env:
AWS_ACCESS_KEY_ID: ${{ secrets.ECR_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.ECR_AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: eu-central-1
ECR_ACCOUNT: 220002198733.dkr.ecr.eu-central-1.amazonaws.com
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build Docker Container
run: |
docker build -t $IMAGE:$GITHUB_RUN_ID -f backend/Dockerfile-prod-be .
Expand All @@ -39,23 +36,20 @@ jobs:
name: Build Strapi Frontend
runs-on: ubuntu-latest
env:
IMAGE: 220002198733.dkr.ecr.eu-central-1.amazonaws.com/cloud-game/strapi/frontend
IMAGE: cloudgame/backend-admin
steps:
- uses: actions/checkout@master
- name: Authenticate
# if: github.ref == 'refs/heads/main'
run: ./.github/scripts/auth.sh
env:
AWS_ACCESS_KEY_ID: ${{ secrets.ECR_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.ECR_AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: eu-central-1
ECR_ACCOUNT: 220002198733.dkr.ecr.eu-central-1.amazonaws.com
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build Docker Container
run: |
cd backend
docker build -t $IMAGE:$GITHUB_RUN_ID -f Dockerfile-prod-fe --build-arg ADMIN_URL=${ADMIN_URL} --build-arg SERVER_URL=${SERVER_URL} .
env:
ADMIN_URL: https://admin.cloud-game.app/
ADMIN_URL: /
SERVER_URL: https://api.cloud-game.app/
- name: Push Container
run: |
Expand Down
21 changes: 12 additions & 9 deletions infrastructure/packer/manifests/basic_gameserver.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -8,35 +8,38 @@ packer {
}

variable "base_image" {
type = string
type = string
default = "debian-11"
}

variable "server_type" {
type = string
type = string
default = "cx11"
}

variable "location" {
type = string
type = string
default = "nbg1"
}

source "hcloud" "basic_gameserver" {
communicator = "ssh"

image = var.base_image
location = var.location
server_type = var.server_type
ssh_username = "root"
image = var.base_image
location = var.location
server_type = var.server_type
ssh_username = "root"
snapshot_name = "basic-gameserver-{{timestamp}}"
snapshot_labels = {
"application": "basic-gameserver"
"application" : "basic-gameserver"
}
}

build {
sources = ["hcloud.basic_gameserver"]

provisioner "file" {
source = "../ansible"
source = "../ansible"
destination = "/tmp/ansible"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ dns = {
"cloud-game.app",
"api.cloud-game.app",
"admin.cloud-game.app",
"ext.cloud-game.app",
]
}

Expand Down

0 comments on commit 2d4384e

Please sign in to comment.