Skip to content

trigger CI/CD

trigger CI/CD #133

Workflow file for this run

name: Create and publish a Docker image
on:
push:
branches: ['main']
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Log in to the Container registry
uses: docker/[email protected]
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Detect changes
uses: dorny/[email protected]
id: changes
with:
filters: |
envoy:
- 'docker/envoy/**'
go:
- 'go/**'
nodejs:
- 'nodejs/**'
webapp:
- 'webapp/**'
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/[email protected]
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Build and push go Docker image
uses: docker/[email protected]
if: steps.changes.outputs.go == 'true'
with:
context: go/
push: true
tags: ${{ env.REGISTRY }}/${{ github.actor }}/cosmos-notifier-go:latest
labels: ${{ steps.meta.outputs.labels }}
- name: Build and push nodejs Docker image
uses: docker/[email protected]
if: steps.changes.outputs.nodejs == 'true'
with:
context: nodejs/
push: true
tags: ${{ env.REGISTRY }}/${{ github.actor }}/cosmos-notifier-nodejs:latest
labels: ${{ steps.meta.outputs.labels }}
- name: Build and push envoy Docker image
uses: docker/[email protected]
if: steps.changes.outputs.envoy == 'true'
with:
context: docker/envoy/
file: docker/envoy/envoy.Dockerfile
push: true
tags: ${{ env.REGISTRY }}/${{ github.actor }}/cosmos-notifier-envoy:latest
labels: ${{ steps.meta.outputs.labels }}
- name: Build and push flutter Docker image
uses: docker/[email protected]
if: steps.changes.outputs.webapp == 'true'
with:
context: webapp/
file: webapp/flutter.Dockerfile
push: true
tags: ${{ env.REGISTRY }}/${{ github.actor }}/cosmos-notifier-webapp:latest
labels: ${{ steps.meta.outputs.labels }}
build-args: CONFIG_FILE=lib/env.dart
- name: Deploy to swarm
uses: wshihadeh/docker-deployment-action@v2
with:
remote_docker_host: [email protected]
ssh_private_key: ${{ secrets.ODIN_SSH_PRIVATE_KEY }}
ssh_public_key: ${{ secrets.ODIN_SSH_PUBLIC_KEY }}
deployment_mode: docker-swarm
copy_stack_file: true
deploy_path: /home/swarm
stack_file_name: swarm-prod-cosmos-notifier.yml
keep_files: 5
args: cosmos-notifier --with-registry-auth