Skip to content

Commit

Permalink
ci(production-cd): add production cd and test
Browse files Browse the repository at this point in the history
  • Loading branch information
DrZIn-dev committed Apr 9, 2022
1 parent 7ff7490 commit 89b51b0
Show file tree
Hide file tree
Showing 3 changed files with 104 additions and 2 deletions.
102 changes: 102 additions & 0 deletions .github/workflows/produciton-cd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
name: Production CD

on:
release:
types: [published]

jobs:
check-file-changed:
runs-on: ubuntu-latest
outputs:
api_changed: ${{ steps.api-changed-files.outputs.any_changed }}
todo_list_changed: ${{ steps.todo-list-changed-files.outputs.any_changed }}
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 2
- name: Get changed files
id: api-changed-files
uses: tj-actions/[email protected]
with:
since_last_remote_commit: 'true'
files: |
api/
- name: Get changed files
id: todo-list-changed-files
uses: tj-actions/[email protected]
with:
since_last_remote_commit: 'true'
files: |
todolist/
api-build-push:
if: needs.check-file-changed.outputs.api_changed == 'true'
needs:
- check-file-changed
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./api
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Log in to GitHub Docker Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build container image
uses: docker/build-push-action@v2
with:
cache-from: type=gha
cache-to: type=gha,mode=max
pull: true
push: true
context: ./api
file: ./api/Dockerfile
target: production
tags: |
ghcr.io/drzin-dev/anodos:${{ steps.get_release.outputs.tag_name }}
api-deploy:
needs:
- api-build-push
runs-on: ubuntu-latest
steps:
- run: echo "dockerize api"
- name: Install SSH Key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.STAGING_PRIVATE_KEY }}
known_hosts: "just-a-placeholder-so-we-dont-get-errors"
- name: Adding Known Hosts
run: ssh-keyscan -H 206.189.38.174 >> ~/.ssh/known_hosts
# - name: Deploy Staging Server
# run: ssh [email protected] 'cd /root/deployment && make DEPLOY_ANODOS_STAGING'

todo-list-build:
if: needs.check-file-changed.outputs.todo_list_changed == 'true'
needs:
- check-file-changed
runs-on: macos-latest
defaults:
run:
working-directory: ./todolist
steps:
- uses: actions/checkout@v2

todo-list-publish-TestFlight:
if: needs.check-file-changed.outputs.todo_list_changed == 'true'
needs:
- todo-list-build
runs-on: macos-latest
defaults:
run:
working-directory: ./todolist
steps:
- uses: actions/checkout@v2
2 changes: 1 addition & 1 deletion .github/workflows/staging-cd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ jobs:
steps:
- uses: actions/checkout@v2

todo-list-publish-test-flight:
todo-list-publish-TestFlight:
if: needs.check-file-changed.outputs.todo_list_changed == 'true'
needs:
- todo-list-build
Expand Down
2 changes: 1 addition & 1 deletion api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "api",
"version": "0.1.3",
"version": "0.1.4",
"description": "",
"author": "",
"private": true,
Expand Down

0 comments on commit 89b51b0

Please sign in to comment.