Skip to content

Commit

Permalink
chore: enable packaging game-db-updater as docker image (#32)
Browse files Browse the repository at this point in the history
- Packages as nighly/latest images
- Does not automatically do so for releases

Closes #31
  • Loading branch information
andrew-codes authored Dec 28, 2023
2 parents d878f51 + 3b89f38 commit 1918dfc
Show file tree
Hide file tree
Showing 15 changed files with 367 additions and 249 deletions.
180 changes: 85 additions & 95 deletions .github/workflows/ppe.yaml
Original file line number Diff line number Diff line change
@@ -1,25 +1,37 @@
name: "PPE"
name: 'Publish dev artifacts (latest dev)'

on:
push:
branches:
- main

permissions:
contents: read

jobs:
unit_tests_linux:
name: Verify Tests (Linux)
runs-on: self-hosted
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Read .nvmrc
run: echo "##[set-output name=NODE_VERSION;]$(cat package.json | jq .engines.node | sed -e 's/"//g' | sed -e 's/>=//g')"
id: nvm
- name: Extract node version from package.json
uses: sergeysova/jq-action@v2
id: node_version
with:
cmd: jq .engines.node package.json -r | sed -e 's/"//g' | sed -e 's/>=//g'
- name: Extract yarn version from package.json
uses: sergeysova/jq-action@v2
id: yarn_version
with:
cmd: jq .engines.yarn package.json -r | sed -e 's/"//g'
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: "${{ steps.nvm.outputs.NODE_VERSION }}"
node-version: '${{ steps.node_version.outputs.value }}'
- name: Use Yarn
run: corepack enable && corepack prepare --activate yarn@${{ steps.yarn_version.outputs.value }}
- name: Install deps
run: yarn
- name: Prepare
Expand All @@ -33,18 +45,31 @@ jobs:

package_for_ppe_linux:
name: Package for PPE (Linux)
runs-on: self-hosted
runs-on: ubuntu-latest
permissions:
packages: write
env:
REGISTRY: ghcr.io
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Read .nvmrc
run: echo "##[set-output name=NODE_VERSION;]$(cat package.json | jq .engines.node | sed -e 's/"//g' | sed -e 's/>=//g')"
id: nvm
- name: Extract node version from package.json
uses: sergeysova/jq-action@v2
id: node_version
with:
cmd: jq .engines.node package.json -r | sed -e 's/"//g' | sed -e 's/>=//g'
- name: Extract yarn version from package.json
uses: sergeysova/jq-action@v2
id: yarn_version
with:
cmd: jq .engines.yarn package.json -r | sed -e 's/"//g'
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: "${{ steps.nvm.outputs.NODE_VERSION }}"
node-version: '${{ steps.node_version.outputs.value }}'
- name: Use Yarn
run: corepack enable && corepack prepare --activate yarn@${{ steps.yarn_version.outputs.value }}
- name: Install deps
run: yarn
- name: Prepare
Expand All @@ -53,61 +78,26 @@ jobs:
ONEPASSWORD_TOKEN: ${{ secrets.ONEPASSWORD_TOKEN }}
ONEPASSWORD_SERVER_URL: ${{ secrets.ONEPASSWORD_SERVER_URL }}
ONEPASSWORD_VAULT_ID: ${{ secrets.ONEPASSWORD_VAULT_ID }}

- name: Package apps
run: yarn nx run-many --target=package --parallel --verbose --projects=tag:linux
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY}}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Publish apps
run: yarn nx affected --target=publish --parallel --base=HEAD~ --head=HEAD --verbose
env:
ONEPASSWORD_TOKEN: ${{ secrets.ONEPASSWORD_TOKEN }}
ONEPASSWORD_SERVER_URL: ${{ secrets.ONEPASSWORD_SERVER_URL }}
ONEPASSWORD_VAULT_ID: ${{ secrets.ONEPASSWORD_VAULT_ID }}
NODE_ENV: production
TAG: ${{ env.REGISTRY }}/${{ github.repository }}:game-db-updater-dev
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: packaged-apps
path: apps/*/.packaged

deploy_ppe:
name: Deploy affected to PPE
runs-on: self-hosted
needs:
- unit_tests_linux
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
ref: main
- name: Read Node version
run: echo "##[set-output name=NODE_VERSION;]$(cat package.json | jq .engines.node | sed -e 's/"//g' | sed -e 's/>=//g')"
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: "${{ steps.nvm.outputs.NODE_VERSION }}"
- uses: actions/setup-dotnet@v2
with:
dotnet-version: "7.0.403"
- name: Install deps
run: yarn
- name: Prepare
run: yarn nx run-many --target=prepare --parallel --all
env:
ONEPASSWORD_TOKEN: ${{ secrets.ONEPASSWORD_TOKEN }}
ONEPASSWORD_SERVER_URL: ${{ secrets.ONEPASSWORD_SERVER_URL }}
ONEPASSWORD_VAULT_ID: ${{ secrets.ONEPASSWORD_VAULT_ID }}

- name: Deploy affected apps
run: yarn nx affected --target=deploy --parallel --verbose --projects=tag:linux
env:
CODECOV_TOKEN: ${{ secrets.CODE_COV_TOKEN }}
ONEPASSWORD_TOKEN: ${{ secrets.ONEPASSWORD_TOKEN }}
ONEPASSWORD_SERVER_URL: ${{ secrets.ONEPASSWORD_SERVER_URL }}
ONEPASSWORD_VAULT_ID: ${{ secrets.ONEPASSWORD_VAULT_ID }}
MQTT_HOST: ${{ secrets.K8S_MAIN_NODE_IP }}
MQTT_PORT: ${{ secrets.MQTT_PORT_EXTERNAL }}
MQTT_USERNAME: ${{ secrets.MQTT_USERNAME }}
MQTT_PASSWORD: ${{ secrets.MQTT_PASSWORD }}
NODE_ENV: production

unit_tests_windows:
name: Verify PR - Tests (Windows)
runs-on: windows-latest
Expand All @@ -123,7 +113,7 @@ jobs:
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: "${{ steps.nvm.outputs.NODE_VERSION }}"
node-version: '${{ steps.nvm.outputs.NODE_VERSION }}'
- name: Enable yarn
run: corepack enable
- run: corepack prepare --activate yarn@^4.0.0
Expand All @@ -138,42 +128,42 @@ jobs:
- name: Run all unit tests
run: yarn nx run-many --target=test/unit --parallel --verbose --projects=tag:windows

package_windows:
name: Package for PPE (Windows)
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Install jq
run: curl -L -o jq.exe https://github.com/stedolan/jq/releases/latest/download/jq-win64.exe
- name: Read .nvmrc
run: echo "##[set-output name=NODE_VERSION;]20.9.0"
id: nvm
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: "${{ steps.nvm.outputs.NODE_VERSION }}"
- name: Enable yarn
run: corepack enable
- run: corepack prepare --activate yarn@^4.0.0
- name: Install deps
run: yarn
- name: Prepare
run: yarn nx run-many --target=prepare --parallel --all --verbose
env:
ONEPASSWORD_TOKEN: ${{ secrets.ONEPASSWORD_TOKEN }}
ONEPASSWORD_SERVER_URL: ${{ secrets.ONEPASSWORD_SERVER_URL }}
ONEPASSWORD_VAULT_ID: ${{ secrets.ONEPASSWORD_VAULT_ID }}
- name: Package apps
run: yarn nx run-many --target=package --parallel --verbose --projects=tag:windows
env:
ONEPASSWORD_TOKEN: ${{ secrets.ONEPASSWORD_TOKEN }}
ONEPASSWORD_SERVER_URL: ${{ secrets.ONEPASSWORD_SERVER_URL }}
ONEPASSWORD_VAULT_ID: ${{ secrets.ONEPASSWORD_VAULT_ID }}
NODE_ENV: production
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: packaged-apps
path: apps/*/.packaged
# package_windows:
# name: Package for PPE (Windows)
# runs-on: windows-latest
# steps:
# - uses: actions/checkout@v4
# with:
# fetch-depth: 2
# - name: Install jq
# run: curl -L -o jq.exe https://github.com/stedolan/jq/releases/latest/download/jq-win64.exe
# - name: Read .nvmrc
# run: echo "##[set-output name=NODE_VERSION;]20.9.0"
# id: nvm
# - name: Use Node.js
# uses: actions/setup-node@v3
# with:
# node-version: "${{ steps.nvm.outputs.NODE_VERSION }}"
# - name: Enable yarn
# run: corepack enable
# - run: corepack prepare --activate yarn@^4.0.0
# - name: Install deps
# run: yarn
# - name: Prepare
# run: yarn nx run-many --target=prepare --parallel --all --verbose
# env:
# ONEPASSWORD_TOKEN: ${{ secrets.ONEPASSWORD_TOKEN }}
# ONEPASSWORD_SERVER_URL: ${{ secrets.ONEPASSWORD_SERVER_URL }}
# ONEPASSWORD_VAULT_ID: ${{ secrets.ONEPASSWORD_VAULT_ID }}
# - name: Publish apps
# run: yarn nx affected --target=publish --parallel --base=HEAD~ --head=HEAD --verbose
# env:
# ONEPASSWORD_TOKEN: ${{ secrets.ONEPASSWORD_TOKEN }}
# ONEPASSWORD_SERVER_URL: ${{ secrets.ONEPASSWORD_SERVER_URL }}
# ONEPASSWORD_VAULT_ID: ${{ secrets.ONEPASSWORD_VAULT_ID }}
# NODE_ENV: production
# - name: Upload artifacts
# uses: actions/upload-artifact@v3
# with:
# name: packaged-apps
# path: apps/*/.packaged
Loading

0 comments on commit 1918dfc

Please sign in to comment.