-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
2 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
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
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 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -88,3 +88,7 @@ sw.* | |
|
||
# Vim swap files | ||
*.swp | ||
|
||
*tfstate* | ||
|
||
.terraform |