pinning node version to fix error #171
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: test and deploy | |
on: [push] | |
env: | |
python-version: '3.11' | |
poetry-version: 1.8.3 | |
node-version: 22.5.1 | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
name: Build & Unit Test | |
steps: | |
- uses: actions/checkout@v4 # get source | |
# PYTHON | |
- name: Install Python ${{ env.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ env.python-version }} | |
# PYTHON dependency management | |
- name: Install Poetry ${{ env.poetry-version }} | |
uses: abatilo/actions-poetry@v2.1.6 | |
with: | |
poetry-version: ${{ env.poetry-version }} | |
# PYTHON install dependencies | |
- name: Install Python Dependencies | |
run: poetry install | |
# PYTHON for authentication when testing | |
- name: Set up Cloud SDK | |
uses: google-github-actions/auth@v0.7.3 | |
with: | |
credentials_json: '${{ secrets.GCP_SA_KEY }}' | |
export_environment_variables: true | |
create_credentials_file: true | |
# PYTHON run unit tests | |
- name: Run Python Tests | |
run: poetry run python -m unittest discover -s tests | |
# JS setup for testing | |
- name: Install Node ${{ env.node-version }} | |
uses: actions/setup-node@v2 | |
with: | |
node-version: ${{ env.node-version }} | |
# JS install from lock.json | |
- name: Install Node Packages | |
run: npm ci | |
# JS build for checking errors | |
- name: Compile Front-end | |
run: npm run build | |
# JS tests | |
# - name: Run JavaScript Tests | |
# run: npm test | |
deploytest: | |
runs-on: ubuntu-latest | |
name: Deploy Test | |
environment: | |
name: test | |
url: https://test.mixonomer.sarsoo.xyz | |
needs: build # for ignoring bad builds | |
if: github.event_name == 'push' | |
steps: | |
- uses: actions/checkout@v4 # get source | |
# PYTHON (pinned to 3.9 for gcloud attribute mapping error) | |
- name: Install Python ${{ env.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ env.python-version }} | |
# PYTHON for dependency export only, not installing | |
- name: Install Poetry ${{ env.poetry-version }} | |
uses: abatilo/actions-poetry@v2.1.6 | |
with: | |
poetry-version: ${{ env.poetry-version }} | |
# PYTHON Export Poetry dependencies as requirements.txt | |
- name: Export Poetry Dependencies | |
run: python admin.py pydepend | |
# JS setup | |
- name: Install Node ${{ env.node-version }} | |
uses: actions/setup-node@v2 | |
with: | |
node-version: ${{ env.node-version }} | |
# JS install from lock.json | |
- name: Install Node Packages | |
run: npm ci | |
# JS will be built again, for flagging errors | |
- name: Compile Front-end | |
run: npm run build --if-present | |
# JS for compiling scss | |
- name: Compile Sass | |
uses: gha-utilities/sass-build@v0.3.5 | |
with: | |
source: src/scss/style.scss | |
destination: build/style.css | |
# DEPLOY for setting up cloud API | |
- name: Set up Cloud SDK | |
uses: google-github-actions/auth@v0.7.3 | |
with: | |
credentials_json: '${{ secrets.GCP_SA_KEY }}' | |
export_environment_variables: true | |
create_credentials_file: true | |
# DEPLOY set project | |
- name: Set GCP Project | |
run: python admin.py set_project ${{ vars.GCP_PROJECT }} | |
# DEPLOY app engine service, -nb for skipping compile | |
- name: Deploy App Engine Service | |
run: python admin.py app -nb | |
- name: Set Test Dispatch Rules | |
run: | | |
cp dispatch.test.yaml dispatch.yaml | |
shell: bash | |
# DEPLOY domain routes | |
- name: Deploy dispatch.yaml | |
run: gcloud app deploy dispatch.yaml --quiet | |
### MAIN FUNCTIONS | |
# DEPLOY update_tag function | |
- name: Deploy update_tag Function | |
run: python admin.py tag ${{ vars.GCP_PROJECT }} | |
# DEPLOY run_user_playlist function | |
- name: Deploy run_user_playlist Function | |
run: python admin.py playlist ${{ vars.GCP_PROJECT }} | |
### CRON FUNCTIONS | |
# DEPLOY run_all_playlists function | |
- name: Deploy run_all_playlists Function | |
run: python admin.py playlist_cron ${{ vars.GCP_PROJECT }} | |
# DEPLOY run_all_playlist_stats function | |
- name: Deploy run_all_playlist_stats Function | |
run: python admin.py playlist_stats_cron ${{ vars.GCP_PROJECT }} | |
# DEPLOY run_all_tags function | |
- name: Deploy run_all_tags Function | |
run: python admin.py tags_cron ${{ vars.GCP_PROJECT }} | |
documentation: | |
runs-on: ubuntu-latest | |
name: Build & Deploy Documentation | |
needs: deployprod # for ignoring bad builds | |
if: github.event_name == 'push' && github.ref == 'refs/heads/master' | |
steps: | |
- uses: actions/checkout@v4 # get source | |
# PYTHON | |
- name: Install Python ${{ env.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ env.python-version }} | |
# PYTHON for dependency export only, not installing | |
- name: Install Poetry ${{ env.poetry-version }} | |
uses: abatilo/actions-poetry@v2.1.6 | |
with: | |
poetry-version: ${{ env.poetry-version }} | |
# PYTHON install dependencies | |
- name: Install Python Dependencies | |
run: poetry install | |
# # JS setup for jsdoc | |
# - name: Install Node ${{ env.node-version }} | |
# uses: actions/setup-node@v2 | |
# with: | |
# node-version: ${{ env.node-version }} | |
# # JS setup for jsdoc | |
# - name: Install jsdoc | |
# run: npm install jsdoc | |
# # JS setup for jsdoc | |
# - name: Add node_modules/.bin to PATH | |
# run: echo "${GITHUB_WORKSPACE}/node_modules/.bin" >> $GITHUB_PATH | |
# DEPLOY for setting up cloud API | |
- name: Set up Cloud SDK | |
uses: google-github-actions/auth@v0.7.3 | |
with: | |
credentials_json: '${{ secrets.GCP_SA_KEY }}' | |
export_environment_variables: true | |
create_credentials_file: true | |
- name: Generate Documentation | |
run: poetry run sphinx-build docs public -b html | |
- name: Write CNAME | |
run: echo docs.mixonomer.sarsoo.xyz > ./public/CNAME | |
- name: Deploy To Pages | |
uses: peaceiris/actions-gh-pages@v3 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_dir: ./public | |
package: | |
runs-on: ubuntu-latest | |
name: Package & Push Container | |
needs: [build] # for ignoring bad builds | |
if: github.event_name == 'push' && github.ref == 'refs/heads/master' | |
steps: | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Login to DockerHub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build & Push Container | |
uses: docker/build-push-action@v2 | |
with: | |
push: true | |
platforms: linux/amd64,linux/arm64 | |
tags: sarsoo/mixonomer:latest | |
deployprod: | |
runs-on: ubuntu-latest | |
name: Deploy Production | |
environment: | |
name: prod | |
url: https://mixonomer.sarsoo.xyz | |
needs: deploytest # for ignoring bad builds | |
if: github.event_name == 'push' && github.ref == 'refs/heads/master' | |
steps: | |
- uses: actions/checkout@v4 # get source | |
# PYTHON (pinned to 3.9 for gcloud attribute mapping error) | |
- name: Install Python ${{ env.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ env.python-version }} | |
# PYTHON for dependency export only, not installing | |
- name: Install Poetry ${{ env.poetry-version }} | |
uses: abatilo/actions-poetry@v2.1.6 | |
with: | |
poetry-version: ${{ env.poetry-version }} | |
# PYTHON Export Poetry dependencies as requirements.txt | |
- name: Export Poetry Dependencies | |
run: python admin.py pydepend | |
# JS setup | |
- name: Install Node ${{ env.node-version }} | |
uses: actions/setup-node@v2 | |
with: | |
node-version: ${{ env.node-version }} | |
# JS install from lock.json | |
- name: Install Node Packages | |
run: npm ci | |
# JS will be built again, for flagging errors | |
- name: Compile Front-end | |
run: npm run build --if-present | |
# JS for compiling scss | |
- name: Compile Sass | |
uses: gha-utilities/sass-build@v0.3.5 | |
with: | |
source: src/scss/style.scss | |
destination: build/style.css | |
# DEPLOY for setting up cloud API | |
- name: Set up Cloud SDK | |
uses: google-github-actions/auth@v0.7.3 | |
with: | |
credentials_json: '${{ secrets.GCP_SA_KEY }}' | |
export_environment_variables: true | |
create_credentials_file: true | |
# DEPLOY set project | |
- name: Set GCP Project | |
run: python admin.py set_project ${{ vars.GCP_PROJECT }} | |
# DEPLOY app engine service, -nb for skipping compile | |
- name: Deploy App Engine Service | |
run: python admin.py app -nb | |
# DEPLOY domain routes | |
- name: Deploy dispatch.yaml | |
run: gcloud app deploy dispatch.yaml --quiet | |
### MAIN FUNCTIONS | |
# DEPLOY update_tag function | |
- name: Deploy update_tag Function | |
run: python admin.py tag ${{ vars.GCP_PROJECT }} | |
# DEPLOY run_user_playlist function | |
- name: Deploy run_user_playlist Function | |
run: python admin.py playlist ${{ vars.GCP_PROJECT }} | |
### CRON FUNCTIONS | |
# DEPLOY run_all_playlists function | |
- name: Deploy run_all_playlists Function | |
run: python admin.py playlist_cron ${{ vars.GCP_PROJECT }} | |
# DEPLOY run_all_playlist_stats function | |
- name: Deploy run_all_playlist_stats Function | |
run: python admin.py playlist_stats_cron ${{ vars.GCP_PROJECT }} | |
# DEPLOY run_all_tags function | |
- name: Deploy run_all_tags Function | |
run: python admin.py tags_cron ${{ vars.GCP_PROJECT }} |