Skip to content

Merge pull request #125 from CommitField/dev #24

Merge pull request #125 from CommitField/dev

Merge pull request #125 from CommitField/dev #24

Workflow file for this run

name: 'deploy'
on:
push:
paths:
- '.github/workflows/**'
- 'src/**'
- 'build.gradle'
- 'Dockerfile'
- 'readme.md'
- 'infraScript/**'
branches:
- 'main'
jobs:
makeTagAndRelease:
runs-on: ubuntu-latest
outputs:
tag_name: ${{ steps.create_tag.outputs.new_tag }}
steps:
- uses: actions/checkout@v4
- name: Create Tag
id: create_tag
uses: mathieudutour/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.create_tag.outputs.new_tag }}
release_name: Release ${{ steps.create_tag.outputs.new_tag }}
body: ${{ steps.create_tag.outputs.changelog }}
draft: false
prerelease: false
buildImageAndPush:
name: ๋„์ปค ์ด๋ฏธ์ง€ ๋นŒ๋“œ์™€ ํ‘ธ์‹œ
needs: makeTagAndRelease
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Docker Buildx ์„ค์น˜
uses: docker/setup-buildx-action@v2
- name: ๋ ˆ์ง€์ŠคํŠธ๋ฆฌ ๋กœ๊ทธ์ธ
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: set lower case owner name
run: |
echo "OWNER_LC=${OWNER,,}" >> ${GITHUB_ENV}
env:
OWNER: "${{ github.repository_owner }}"
- name: application-secret.yml ์ƒ์„ฑ
env:
ACTIONS_STEP_DEBUG: true
APPLICATION_SECRET: ${{ secrets.APPLICATION_SECRET_YML }}
run: echo "$APPLICATION_SECRET" > src/main/resources/application-secret.yml
- name: ๋นŒ๋“œ ์•ค ํ‘ธ์‹œ
uses: docker/build-push-action@v3
with:
context: .
push: true
tags: |
ghcr.io/${{ env.OWNER_LC }}/commitfield:${{ needs.makeTagAndRelease.outputs.tag_name }},
ghcr.io/${{ env.OWNER_LC }}/commitfield:latest
deploy:
runs-on: ubuntu-latest
needs: [ buildImageAndPush ]
steps:
- name: AWS SSM Send-Command
uses: peterkimzz/aws-ssm-send-command@master
id: ssm
with:
aws-region: ${{ secrets.AWS_REGION }}
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
instance-ids: "i-0e27758b937bcc047"
working-directory: /
comment: Deploy
command: |
mkdir -p /dockerProjects/cmf
curl -o /dockerProjects/cmf/zero_downtime_deploy.py https://raw.githubusercontent.com/CommitField/commitfield/main/infraScript/zero_downtime_deploy.py
chmod +x /dockerProjects/cmf/zero_downtime_deploy.py
/dockerProjects/cmf/zero_downtime_deploy.py