-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #173 from sparcs-kaist/feat/production-deploy-on-r…
…elease
- Loading branch information
Showing
5 changed files
with
100 additions
and
6 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
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
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,40 @@ | ||
name: Build docker image on release tag created | ||
|
||
on: | ||
push: | ||
tags: | ||
- v** | ||
|
||
jobs: | ||
build: | ||
name: Build and push Image to GitHub Container Registry | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
- name: Cache Docker layers | ||
uses: actions/cache@v3 | ||
with: | ||
path: /tmp/.buildx-cache | ||
key: ${{ runner.os }}-buildx-${{ github.sha }} | ||
restore-keys: | | ||
${{ runner.os }}-buildx- | ||
- name: Log in to GitHub Container Registry | ||
run: echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u USERNAME --password-stdin | ||
- name: Build and push Image | ||
id: docker-build | ||
uses: docker/build-push-action@v5 | ||
env: | ||
IMAGE_TAG: ${{github.ref_name}} | ||
with: | ||
push: true | ||
tags: | | ||
"ghcr.io/sparcs-kaist/zabo-front:${{ env.IMAGE_TAG }}" | ||
"ghcr.io/sparcs-kaist/zabo-front:latest" | ||
cache-from: type=local,src=/tmp/.buildx-cache | ||
cache-to: type=local,dest=/tmp/.buildx-cache-new | ||
- name: Remove old cache | ||
run: | | ||
rm -rf /tmp/.buildx-cache | ||
mv /tmp/.buildx-cache-new /tmp/.buildx-cache |
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,32 @@ | ||
name: Deploy to prod server | ||
|
||
# when prod image build action is completed, run this action | ||
on: | ||
workflow_run: | ||
workflows: ["Build docker image on release tag created"] | ||
types: | ||
- completed | ||
|
||
jobs: | ||
if_workflow_success: | ||
name: Deploy to dev server | ||
runs-on: ubuntu-latest | ||
if: ${{ github.event.workflow_run.conclusion == 'success' }} | ||
|
||
steps: | ||
- name: pull the image and restart the container | ||
uses: appleboy/ssh-action@v1.0.0 | ||
with: | ||
host: ${{ secrets.PROD_HOST }} | ||
port: ${{ secrets.PROD_PORT }} | ||
username: ${{ secrets.PROD_USERNAME }} | ||
password: ${{ secrets.PROD_PASSWORD }} | ||
proxy_host: ${{ secrets.PROD_PROXY_HOST }} | ||
proxy_port: ${{ secrets.PROD_PROXY_PORT }} | ||
proxy_username: ${{ secrets.PROD_PROXY_USERNAME }} | ||
proxy_password: ${{ secrets.PROD_PROXY_PASSWORD }} | ||
script_stop: true # stop script if any command has failed | ||
script: | | ||
docker pull ghcr.io/sparcs-kaist/zabo-front:latest | ||
docker rm -f zabo-front | ||
docker run --restart always -d -p ${{ secrets.PROD_CONTAINER_PORT }}:80 --name zabo-front ghcr.io/sparcs-kaist/zabo-front:latest |
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,23 @@ | ||
# This workflow was created by Ted Park | ||
# Source: https://medium.com/prnd/github%EC%97%90%EC%84%9C-release-tag-%EC%9E%90%EB%8F%99%EC%9C%BC%EB%A1%9C-%EB%A7%8C%EB%93%A4%EC%96%B4-%EC%A3%BC%EA%B8%B0-1%EB%B6%84%EB%A7%8C%EC%97%90-%EC%84%A4%EC%A0%95-5c09a383fb08 | ||
|
||
name: Create Release Tag on push to main | ||
on: | ||
push: | ||
branches: | ||
- main | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Extract tag version | ||
run: echo "##[set-output name=version;]$(echo '${{ github.event.head_commit.message }}' | egrep -o '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}')" | ||
id: extract_version_name | ||
- name: Create release with tag | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: ${{ steps.extract_version_name.outputs.version }} | ||
release_name: ${{ steps.extract_version_name.outputs.version }} |