Skip to content

New Google tag

New Google tag #41

Workflow file for this run

# ## NOTE
#
# - env (prod, staging) is different from MIX_ENV which will always be prod
name: Production
on:
push:
branches:
- master
jobs:
build:
name: Deploy
strategy:
matrix:
app: [pairs_one]
host: [pairs.one]
env: [prod]
os: [ubuntu-latest]
port: [8010]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Log into GHCR
run: echo "${{secrets.GITHUB_TOKEN}}" | docker login https://ghcr.io -u ${{github.actor}} --password-stdin
- name: Build and push
uses: docker/build-push-action@v3
with:
push: true
tags: ghcr.io/mxgrn/${{matrix.app}}:latest
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Pull image on host and restart
uses: appleboy/ssh-action@master
with:
host: ${{secrets.APP_HOSTS}}
sync: true
username: deploy
key: ${{ secrets.DEPLOYMENT_KEY }}
script_stop: true
script: |
echo "${{secrets.GITHUB_TOKEN}}" | docker login https://ghcr.io -u ${{github.actor}} --password-stdin
docker pull ghcr.io/mxgrn/${{matrix.app}}
docker stop ${{matrix.app}}_${{matrix.env}} || true
docker rm ${{matrix.app}}_${{matrix.env}} || true
docker run --name=${{matrix.app}}_${{matrix.env}} -d \
--restart always \
--network host \
-e PORT=${{matrix.port}} \
-e SECRET_KEY_BASE=${{secrets.SECRET_KEY_BASE}} \
-e REDIS_URI=${{secrets.REDIS_URI}} \
-e GITHUB_SHA=${{github.sha}} \
-e SENTRY_DSN=${{secrets.SENTRY_DSN}} \
-e RELEASE_COOKIE=${{secrets.RELEASE_COOKIE}} \
-e PHX_HOST=${{matrix.host}} \
-e DOCKER_CONTAINER=${{matrix.app}}_${{matrix.env}} \
-e PROD_ENV=${{matrix.env}} \
ghcr.io/mxgrn/${{matrix.app}}
while [ "`docker inspect -f {{.State.Running}} ${{matrix.app}}_${{matrix.env}}`" != "true" ]; do sleep 1; done
sleep 10
echo "Done."