Skip to content

Deploy timeline

Deploy timeline #14

Workflow file for this run

name: Deploy timeline
on:
push:
branches:
- main
env:
SWARM_HOSTNAME: ${{ secrets.SWARM_HOSTNAME }} # Organization secret
SWARM_USERNAME: ${{ secrets.SWARM_USERNAME }} # Organization secret
SWARM_PASSWORD: ${{ secrets.SWARM_PASSWORD }} # Organization secret
SWARM_SSH_PORT: ${{ secrets.SWARM_SSH_PORT }} # Organization secret
REGISTRY: ghcr.io
BRANCH_REF: main
jobs:
build:
runs-on: ubuntu-latest
env:
IMAGE_NAME: ${{ github.repository }}
outputs:
image: ${{ steps.meta.outputs.tags }}
steps:
- name: Checkout source code
uses: actions/checkout@master
with:
ref: ${{ env.BRANCH_REF }}
- name: Log in to the Container registry
uses: docker/login-action@master
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@master
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=sha
- name: Build and push
uses: docker/build-push-action@master
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
deploy:
needs: [build]
env:
DEPLOY_SOURCE: deploy/stack.yml
STACK_COMPOSE_PATH: /home/runner/timeline/deploy/stack.yml
STACK_CONFIG_PATH: /home/runner/timeline/deploy/stack.env
runs-on: saeon
steps:
- name: Check out source code (shared)
uses: actions/checkout@master
with:
ref: ${{ env.BRANCH_REF }}
- name: (SCP) Copy stack configuration to app server
uses: appleboy/scp-action@master
with:
host: ${{ env.SWARM_HOSTNAME }}
username: ${{ env.SWARM_USERNAME }}
password: ${{ env.SWARM_PASSWORD }}
port: ${{ env.SWARM_SSH_PORT }}
source: ${{ env.DEPLOY_SOURCE }}
target: "timeline"
- name: (SSH) Deploy stack
uses: appleboy/ssh-action@master
with:
host: ${{ env.SWARM_HOSTNAME }}
username: ${{ env.SWARM_USERNAME }}
password: ${{ env.SWARM_PASSWORD }}
port: ${{ env.SWARM_SSH_PORT }}
script: |
echo "DOCKER_IMAGE=${{ needs.build.outputs.image }}" > ${{ env.STACK_CONFIG_PATH }}
sudo /opt/deploy-docker-stack.sh ${{ env.STACK_COMPOSE_PATH }} ${{ env.STACK_CONFIG_PATH }} timeline