update workflow #40
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy develop | |
on: | |
push: | |
branches: | |
- develop | |
workflow_dispatch: | |
env: | |
APP_NAME: hibon-service | |
PROJECT_NAME: dev-hibon-service | |
jobs: | |
test: | |
name: Run Tests | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Cache node modules | |
uses: actions/cache@v2 | |
with: | |
path: node_modules | |
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-node- | |
- name: Install PM2 globally | |
run: npm install pm2 -g | |
- name: Install Dependencies | |
run: npm install | |
- name: Install hibonutil | |
run: | | |
mkdir -p artifact | |
cd artifact | |
gh release download v1.0.0 --repo tagion/tagion --pattern "successful_artifact.zip" | |
unzip successful_artifact.zip | |
rm -r successful_artifact.zip | |
tar -xzf *.tar.gz | |
rm -r *.tar.gz | |
cd build/x86_64-linux/bin | |
ln -s tagion hibonutil | |
chmod +x hibonutil | |
cp hibonutil /usr/local/bin/ | |
- name: Run Jest Tests | |
run: npm test | |
deploy: | |
needs: test | |
name: Build Image | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Configure AWS Credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: ${{ secrets.AWS_DEFAULT_REGION }} | |
- name: Login to Amazon ECR | |
id: login-ecr | |
uses: aws-actions/amazon-ecr-login@v1 | |
- name: Build, tag, and push image to Amazon ECR | |
env: | |
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | |
ECR_REPOSITORY: hibon-service | |
IMAGE_TAG: ${{ github.sha }} | |
run: | | |
docker build --build-arg GITBOT_TOKEN=${{ secrets.GITBOT_TOKEN }} -t $ECR_REGISTRY/$ECR_REPOSITORY:latest . | |
docker push -a $ECR_REGISTRY/$ECR_REPOSITORY | |
- name: Update kube config | |
run: | | |
aws eks update-kubeconfig --name eks --region ${{ secrets.AWS_DEFAULT_REGION }} | |
- name: Deploy to EKS | |
run: | | |
kubectl delete deploy $PROJECT_NAME || echo "old deploy deleted" | |
kubectl apply -f k8s/dev_deployment.yml |