Updates todo #416
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: ci | |
on: | |
push: | |
branches: | |
- "master" | |
pull_request: | |
branches: | |
- "master" | |
jobs: | |
docker: | |
runs-on: ubuntu-latest | |
environment: Tests | |
services: | |
redis: | |
image: redis:6 | |
ports: | |
- 6379:6379 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
# if we don't fetch the history | |
# the news page will not be generated properly (it uses git) | |
with: | |
fetch-depth: 300 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Log in to GitHub Container Registry | |
uses: docker/login-action@v1 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Get Redis network name | |
id: redis_network | |
run: echo "::set-output name=network_name::$(docker network ls --filter name=_default -q)" | |
- name: Build and export to Docker | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
load: true | |
tags: ghcr.io/${{ github.repository_owner }}/blot:test-${{ github.sha }} | |
target: test | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
- name: Test | |
env: | |
BLOT_STRIPE_KEY: ${{ secrets.BLOT_STRIPE_KEY }} | |
BLOT_STRIPE_SECRET: ${{ secrets.BLOT_STRIPE_SECRET }} | |
BLOT_STRIPE_PRODUCT: ${{ secrets.BLOT_STRIPE_PRODUCT }} | |
# the docker run environment is different from the docker-compose environment | |
# so we need to pass in these variables explicitly | |
run: | | |
docker run --rm \ | |
--network name=${{ job.services.redis.network }} \ | |
-e BLOT_REDIS_HOST=redis \ | |
-e BLOT_STRIPE_KEY=$BLOT_STRIPE_KEY \ | |
-e BLOT_STRIPE_SECRET=$BLOT_STRIPE_SECRET \ | |
-e BLOT_STRIPE_PRODUCT=$BLOT_STRIPE_PRODUCT \ | |
ghcr.io/${{ github.repository_owner }}/blot:test-${{ github.sha }} sh -c "node tests && npx depcheck --ignores=depcheck,nodemon,blessed-contrib,twit,fontkit,text-to-svg --skip-missing" | |
# this step should only run on pushes to master | |
# otherwise, pull requests will produce a production image | |
- name: Build production image | |
uses: docker/build-push-action@v5 | |
if: github.ref == 'refs/heads/master' | |
with: | |
context: . | |
platforms: linux/amd64,linux/arm64 | |
push: true | |
tags: ghcr.io/${{ github.repository_owner }}/blot:latest | |
target: prod | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
- name: Deploy | |
if: github.ref == 'refs/heads/master' | |
run: | | |
echo "Deploying to production" |