Skip to content

Commit

Permalink
(wip) ci updates
Browse files Browse the repository at this point in the history
  • Loading branch information
hburn7 committed Aug 22, 2024
1 parent 3892e2e commit e50b89a
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 0 deletions.
File renamed without changes.
Empty file.
File renamed without changes.
85 changes: 85 additions & 0 deletions .github/workflows/staging-deploy-dataworker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: .NET CI/CD

on:
push:
branches: [ master ]
paths:
- DataWorkerService
- DataWorkerService.Tests
- Common
- Database

jobs:
build_test:
runs-on: ubuntu-latest

steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
ref: master

- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: '8.0.x'

- name: Restore Dependencies
run: dotnet restore

- name: Build
run: dotnet build -c Release --no-restore

- name: Test
run: dotnet test ./APITests/APITests.csproj -c Release --verbosity normal

publish:
needs: build_test
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
ref: master
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: stagecodes
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and Push Docker Image
run: |
docker build -t stagecodes/otr-api-staging .
docker push stagecodes/otr-api-staging
deploy:
environment: Staging
needs: publish
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
ref: master
- name: Create .env files
run: |
echo "${{ secrets.APP_ENV }}" > app.env
echo "${{ secrets.DB_ENV }}" > db.env
echo "${{ secrets.POSTGRES_EXPORTER_ENV }}" > postgres_exporter.env
- name: Copy files to server
uses: appleboy/scp-action@master
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USER }}
key: ${{ secrets.SSH_KEY }}
source: "app.env,db.env,postgres_exporter.env,docker-compose-staging.yml,otel-collector-config.yml,prometheus.yml"
target: "~/otr-api/"
- name: Deploy
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USER }}
key: ${{ secrets.SSH_KEY }}
script: |
cd ~/otr-api
docker compose -f docker-compose-staging.yml pull
docker compose -f docker-compose-staging.yml up -d --build

0 comments on commit e50b89a

Please sign in to comment.