-
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.
* chore(github): Issue Template Label 수정 * ci: 배포 workflow 수정
- Loading branch information
1 parent
8de0b91
commit a5173e5
Showing
5 changed files
with
144 additions
and
53 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,139 @@ | ||
name: Deploy | ||
run-name: Deploy (${{ github.event.workflow_run.head_branch }}) | ||
|
||
on: | ||
workflow_run: | ||
workflows: | ||
- Test | ||
types: | ||
- completed | ||
branches: | ||
- master | ||
- develop | ||
|
||
concurrency: | ||
group: deploy-${{ github.event.workflow_run.head_branch }} | ||
cancel-in-progress: true | ||
|
||
env: | ||
IMAGE_NAME: ${{ secrets.DOCKERHUB_USERNAME }}/wink-official-backend:${{ github.event.workflow_run.head_branch }} | ||
|
||
SSH_HOST: ${{ github.event.workflow_run.head_branch == 'master' && secrets.SSH_MASTER_HOST || secrets.SSH_DEVELOP_HOST }} | ||
SSH_USERNAME: ${{ github.event.workflow_run.head_branch == 'master' && secrets.SSH_MASTER_USERNAME || secrets.SSH_DEVELOP_USERNAME }} | ||
SSH_KEY: ${{ github.event.workflow_run.head_branch == 'master' && secrets.SSH_MASTER_KEY || secrets.SSH_DEVELOP_KEY }} | ||
|
||
jobs: | ||
build-amd64: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Login to Docker Hub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_ACCESS_TOKEN }} | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Build Image | ||
uses: docker/build-push-action@v6 | ||
with: | ||
push: true | ||
platforms: linux/amd64 | ||
provenance: false | ||
tags: ${{ env.IMAGE_NAME }}-amd64 | ||
cache-from: type=registry,ref=${{ env.IMAGE_NAME }}-amd64-cache | ||
cache-to: type=registry,ref=${{ env.IMAGE_NAME }}-amd64-cache | ||
|
||
build-arm64: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Login to Docker Hub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_ACCESS_TOKEN }} | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Build Image | ||
uses: docker/build-push-action@v6 | ||
with: | ||
push: true | ||
platforms: linux/arm64 | ||
tags: ${{ env.IMAGE_NAME }}-arm64 | ||
provenance: false | ||
cache-from: type=registry,ref=${{ env.IMAGE_NAME }}-arm64-cache | ||
cache-to: type=registry,ref=${{ env.IMAGE_NAME }}-arm64-cache | ||
|
||
merge-image: | ||
runs-on: ubuntu-latest | ||
needs: [ build-amd64, build-arm64 ] | ||
steps: | ||
- name: Login to Docker Hub | ||
run: | | ||
echo "${{ secrets.DOCKERHUB_ACCESS_TOKEN }}" | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin | ||
- name: Pull Backend Image | ||
run: | | ||
docker pull --platform linux/amd64 ${{ env.IMAGE_NAME }}-amd64 | ||
docker pull --platform linux/arm64 ${{ env.IMAGE_NAME }}-arm64 | ||
- name: Merge Backend Image | ||
run: | | ||
docker manifest create ${{ env.IMAGE_NAME }} ${{ env.IMAGE_NAME }}-amd64 ${{ env.IMAGE_NAME }}-arm64 | ||
docker manifest annotate ${{ env.IMAGE_NAME }} ${{ env.IMAGE_NAME }}-amd64 --os linux --arch amd64 | ||
docker manifest annotate ${{ env.IMAGE_NAME }} ${{ env.IMAGE_NAME }}-arm64 --os linux --arch arm64 | ||
- name: Push Backend Image | ||
run: docker manifest push ${{ env.IMAGE_NAME }} | ||
|
||
check-server: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check exists project | ||
uses: appleboy/[email protected] | ||
with: | ||
host: ${{ env.SSH_HOST }} | ||
username: ${{ env.SSH_USERNAME }} | ||
key: ${{ env.SSH_KEY }} | ||
script: | | ||
if [ ! -d "Backend" ]; then | ||
echo "Directory "Backend" not found" | ||
exit 1 | ||
fi | ||
- name: Check docker compose file | ||
uses: appleboy/[email protected] | ||
with: | ||
host: ${{ env.SSH_HOST }} | ||
username: ${{ env.SSH_USERNAME }} | ||
key: ${{ env.SSH_KEY }} | ||
script: | | ||
if [ ! -f "Backend/docker-compose.yaml" ]; then | ||
echo "File "Backend/docker-compose.yaml" not found" | ||
exit 1 | ||
fi | ||
deploy: | ||
runs-on: ubuntu-latest | ||
needs: [ check-server, build-amd64 ] | ||
steps: | ||
- name: Deploy | ||
uses: appleboy/[email protected] | ||
with: | ||
host: ${{ env.SSH_HOST }} | ||
username: ${{ env.SSH_USERNAME }} | ||
key: ${{ env.SSH_KEY }} | ||
script: | | ||
cd Backend | ||
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
This file was deleted.
Oops, something went wrong.