Skip to content

Commit

Permalink
add github workflow
Browse files Browse the repository at this point in the history
tinhtq committed May 25, 2024
1 parent 0f1d84c commit 9dc51a5
Showing 2 changed files with 69 additions and 0 deletions.
65 changes: 65 additions & 0 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Deploy to EC2
on:
push:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set SHA-COMMIT
id: vars
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Build and push
uses: docker/build-push-action@v5
with:
context: back
platforms: linux/amd64
push: true
tags: |
ghcr.io/tinhtq/example-project-backend:latest
ghcr.io/tinhtq/example-project-backend:${{ steps.vars.outputs.sha_short }}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: front
platforms: linux/amd64
push: true
tags: |
ghcr.io/tinhtq/example-project-frontend:latest
ghcr.io/tinhtq/example-project-frontend:${{ steps.vars.outputs.sha_short }}
# deploy:
# needs: build
# runs-on: ubuntu-latest
# timeout-minutes: 5
# steps:
# - name: Deploy
# uses: appleboy/ssh-action@v1.0.3
# with:
# host: ${{ secrets.EC2_HOST }}
# username: ${{ secrets.EC2_USERNAME }}
# key: ${{ secrets.KEY }}
# port: ${{ secrets.PORT }}
# command_timeout: 30m
# script: |
# cd ${{ vars.DIRECTORY }}
# docker compose pull
# docker compose up -d
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -88,3 +88,7 @@ sw.*

# Vim swap files
*.swp

*tfstate*

.terraform

0 comments on commit 9dc51a5

Please sign in to comment.