Skip to content

Commit

Permalink
chore(core): app deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
tericcabrel committed Sep 3, 2022
1 parent 7636ee3 commit 3593e67
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 30 deletions.
24 changes: 0 additions & 24 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
name: Sharingan Build
on:
push:
branches: [ main ]
paths-ignore:
- '**/.md'
pull_request:
branches: [ main ]
paths-ignore:
- '**/.md'
env:
COMMIT_SHA: ${{ github.event.pull_request.head.sha }}

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
Expand Down Expand Up @@ -51,21 +45,3 @@ jobs:

- name: Run tests
run: yarn test

trigger_deploy:
if: ${{ github.ref == 'refs/heads/main' }}
name: trigger_deploy
needs: [ build ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Trigger deployment
run: |
set -e
GITHUB_TOKEN=${{ github.token }}
SHA=${COMMIT_SHA:=latest}
echo $SHA
curl -X POST -H "Accept: application/vnd.github.v3+json" -H "Authorization: token $GITHUB_TOKEN" https://api.github.com/repos/tericcabrel/sharingan/actions/workflows/deploy-core.yml/dispatches -d '{"ref": "main", "inputs": {"commit-sha": "'"$SHA"'"}}'
43 changes: 37 additions & 6 deletions .github/workflows/deploy-core.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
name: Sharingan Deploy Core
on:
workflow_dispatch:
inputs:
commit-sha:
description: "SHA of the latest commit in the pull request"
required: true
pull_request:
branches:
- main
push:
branches:
- main
- dev
paths:
- 'apps/core/src/**'

env:
IMAGE_TAG: tericcabrel/sharingan-core:${{ github.event.inputs.commit-sha }}
IMAGE_TAG: tericcabrel/sharingan-core:${{ github.sha }}

jobs:
package:
if: false
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand All @@ -37,7 +42,33 @@ jobs:
push: true
tags: ${{ env.IMAGE_TAG }}

package-ecr:
runs-on: ubuntu-latest
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}
steps:
- uses: actions/checkout@v2

- name: Login to Amazon ECR
id: ecr-login
uses: aws-actions/amazon-ecr-login@v1
with:
registry-type: public

- name: Build, tag, and push docker image to Amazon ECR
env:
REGISTRY: ${{ steps.login-ecr-public.outputs.registry }}
REGISTRY_ALIAS: x9y5g9l2
REPOSITORY: sharingan
IMAGE_TAG: ${{ github.sha }}
run: |
docker build -t $REGISTRY/$REGISTRY_ALIAS/$REPOSITORY:$IMAGE_TAG .
docker push $REGISTRY/$REGISTRY_ALIAS/$REPOSITORY:$IMAGE_TAG
deploy:
if: false
defaults:
run:
working-directory: apps/core
Expand Down

0 comments on commit 3593e67

Please sign in to comment.