Deploy #541
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: | |
workflow_run: | |
workflows: ["Test"] | |
branches: [main] | |
types: | |
- completed | |
workflow_dispatch: | |
concurrency: | |
group: deployment | |
cancel-in-progress: true | |
jobs: | |
webpack: | |
name: Run webpack | |
runs-on: ubuntu-latest | |
if: ${{ github.event.workflow_run.conclusion != 'failure' }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
lfs: true | |
- uses: ruby/setup-ruby@v1 | |
with: | |
bundler-cache: true | |
- run: bundle exec rake npm:ci | |
- run: bundle exec rake webpack:prod | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: webpack-components | |
path: | | |
public/css/** | |
public/img/** | |
public/js/** | |
public/manifest.json | |
build: | |
name: Build production image | |
runs-on: ubuntu-latest | |
needs: webpack | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
lfs: true | |
- uses: actions/download-artifact@v4 | |
with: | |
name: webpack-components | |
path: public | |
- uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push docker image | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
file: docker/Dockerfile | |
pull: true | |
push: true | |
tags: ghcr.io/${{ github.repository }}:${{ github.sha }} | |
target: ruby-app | |
dev-deploy: | |
name: Deploy to dev server | |
runs-on: ubuntu-latest | |
environment: development | |
needs: build | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- uses: rickselby-web-server/actions/server-certificate@main | |
with: | |
CA: ${{ secrets.LINODE_CA }} | |
CLIENT_CERT: ${{ secrets.LINODE_CLIENT_CERT }} | |
CLIENT_KEY: ${{ secrets.LINODE_CLIENT_KEY }} | |
- uses: rickselby-web-server/actions/docker-compose-deploy@main | |
with: | |
COMPOSE_FILE_PATH: docker/dev.yml | |
CONNECT_CONTAINERS: nginx-proxy | |
STACK_NAME: ciclos-major-sinatra-dev | |
env: | |
CONTAINER: ghcr.io/${{ github.repository }}:${{ github.sha }} | |
DOCKER_HOST: ${{ secrets.LINODE_HOST }} | |
DOCKER_TLS_VERIFY: 1 | |
LETSENCRYPT_EMAIL: ${{ secrets.LETSENCRYPT_EMAIL }} | |
AD_TENANT: ${{ secrets.AD_TENANT }} | |
AD_CLIENT_ID: ${{ secrets.AD_CLIENT_ID }} | |
AD_CLIENT_SECRET: ${{ secrets.AD_CLIENT_SECRET }} | |
prod-deploy: | |
name: Deploy to production server | |
runs-on: ubuntu-latest | |
environment: production | |
needs: build | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- uses: rickselby-web-server/actions/server-certificate@main | |
with: | |
CA: ${{ secrets.LINODE_CA }} | |
CLIENT_CERT: ${{ secrets.LINODE_CLIENT_CERT }} | |
CLIENT_KEY: ${{ secrets.LINODE_CLIENT_KEY }} | |
- uses: rickselby-web-server/actions/docker-compose-deploy@main | |
with: | |
COMPOSE_FILE_PATH: docker/production.yml | |
CONNECT_CONTAINERS: nginx-proxy | |
STACK_NAME: ciclos-major-sinatra | |
env: | |
CONTAINER: ghcr.io/${{ github.repository }}:${{ github.sha }} | |
DOCKER_HOST: ${{ secrets.LINODE_HOST }} | |
DOCKER_TLS_VERIFY: 1 | |
LETSENCRYPT_EMAIL: ${{ secrets.LETSENCRYPT_EMAIL }} | |
SESSION_SECRET: ${{ secrets.SESSION_SECRET }} | |
AD_TENANT: ${{ secrets.AD_TENANT }} | |
AD_CLIENT_ID: ${{ secrets.AD_CLIENT_ID }} | |
AD_CLIENT_SECRET: ${{ secrets.AD_CLIENT_SECRET }} |