Merge pull request #1827 from gereon77/assign-replaced-vassal-to-rand… #933
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy | |
on: | |
push: | |
branches: | |
- master | |
env: | |
GITHUB_PACKAGES_GAME_SERVER_DOCKER_IMAGE: docker.pkg.github.com/longwelwind/swords-and-ravens/game_server:${{ github.sha }} | |
GITHUB_PACKAGES_WEBSITE_DOCKER_IMAGE: docker.pkg.github.com/longwelwind/swords-and-ravens/website:${{ github.sha }} | |
DOKKU_GAME_SERVER_DOCKER_IMAGE: dokku/play:${{ github.sha }} | |
DOKKU_WEBSITE_DOCKER_IMAGE: dokku/swordsandravens.net:${{ github.sha }} | |
DOKKU_HOST: [email protected] | |
jobs: | |
game-server-docker-build: | |
name: Game Server Docker Image Build | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v1 | |
- name: Login to GitHub Packages | |
run: docker login docker.pkg.github.com -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }} | |
- name: Build game-server Docker image | |
run: docker build -f ./game_server.Dockerfile -t $GITHUB_PACKAGES_GAME_SERVER_DOCKER_IMAGE . | |
- name: Upload Docker image to GitHub Packages | |
run: docker push $GITHUB_PACKAGES_GAME_SERVER_DOCKER_IMAGE | |
website-docker-build: | |
name: Website Docker Image Build | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v1 | |
- name: Login to GitHub Packages | |
run: docker login docker.pkg.github.com -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }} | |
- name: Build game-server Docker image | |
run: docker build -f ./website.Dockerfile -t $GITHUB_PACKAGES_WEBSITE_DOCKER_IMAGE . | |
- name: Upload Docker image to GitHub Packages | |
run: docker push $GITHUB_PACKAGES_WEBSITE_DOCKER_IMAGE | |
build-assets: | |
name: Build game assets | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: ./agot-bg-game-server | |
env: | |
ASSET_PATH: https://swords-and-ravens.ams3.cdn.digitaloceanspaces.com/ | |
steps: | |
- uses: actions/checkout@v1 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 16 | |
- name: Install dependencies | |
run: yarn install --frozen-lockfile | |
- name: Build assets | |
run: yarn run generate-json-schemas && yarn run build-client | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: front-end-game-server | |
path: agot-bg-game-server/dist | |
retention-days: 1 | |
deploy: | |
name: Deploy | |
runs-on: ubuntu-latest | |
needs: [game-server-docker-build, website-docker-build, build-assets] | |
env: | |
SSH_KEY: ${{ secrets.CI_DEPLOY_SSH_KEY }} | |
steps: | |
- name: Login to GitHub Packages | |
run: docker login docker.pkg.github.com -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }} | |
- name: Setup SSH Key | |
run: mkdir -p ~/.ssh && echo "$SSH_KEY" > ~/.ssh/id_rsa && chmod 400 ~/.ssh/id_rsa | |
- name: Pulling Game Server Docker Image | |
run: docker pull $GITHUB_PACKAGES_GAME_SERVER_DOCKER_IMAGE | |
- name: Pulling Website Docker Image | |
run: docker pull $GITHUB_PACKAGES_WEBSITE_DOCKER_IMAGE | |
- name: Tagging Game Server Docker Image | |
run: docker tag $GITHUB_PACKAGES_GAME_SERVER_DOCKER_IMAGE $DOKKU_GAME_SERVER_DOCKER_IMAGE | |
- name: Tagging Website Docker Image | |
run: docker tag $GITHUB_PACKAGES_WEBSITE_DOCKER_IMAGE $DOKKU_WEBSITE_DOCKER_IMAGE | |
- name: Upload Game Server Docker Image to Dokku | |
run: docker save $DOKKU_GAME_SERVER_DOCKER_IMAGE | bzip2 | ssh -o StrictHostKeyChecking=no $DOKKU_HOST "bunzip2 | docker load" | |
- name: Upload Website Docker Image to Dokku | |
run: docker save $DOKKU_WEBSITE_DOCKER_IMAGE | bzip2 | ssh -o StrictHostKeyChecking=no $DOKKU_HOST "bunzip2 | docker load" | |
- name: Deploy Game Server | |
run: ssh -o StrictHostKeyChecking=no $DOKKU_HOST "dokku tags:deploy play ${{ github.sha }}" | |
- name: Deploy Website | |
run: ssh -o StrictHostKeyChecking=no $DOKKU_HOST "dokku tags:deploy swordsandravens.net ${{ github.sha }}" | |
- name: Clean Host | |
run: ssh -o StrictHostKeyChecking=no $DOKKU_HOST "docker system prune -a -f --filter \"until=45m\"" | |
deploy-static-assets: | |
name: Deploy Static Assets | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: ./agot-bg-website | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_LOCATION: ${{ secrets.AWS_LOCATION }} | |
AWS_S3_ENDPOINT_URL: ${{ secrets.AWS_S3_ENDPOINT_URL }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
AWS_STORAGE_BUCKET_NAME: ${{ secrets.AWS_STORAGE_BUCKET_NAME }} | |
needs: [build-assets] | |
steps: | |
- uses: actions/checkout@v1 | |
- uses: actions/setup-python@v3 | |
with: | |
python-version: '3.8.16' | |
- name: Install python dependencies | |
run: pip install -r requirements.txt | |
- name: Copy dev config | |
run: mv .env.dev .env | |
- name: Download static assets | |
uses: actions/download-artifact@v3 | |
with: | |
name: front-end-game-server | |
path: agot-bg-website/dist/ | |
- name: Copy assets | |
run: cp -r dist/. static_game/ | |
- name: Upload assets | |
run: DEBUG=0 NO_DATABASE=1 python manage.py collectstatic --no-input |