diff --git a/.github/workflows/ci-workflow.yml b/.github/workflows/ci-workflow.yml deleted file mode 100644 index daa602a..0000000 --- a/.github/workflows/ci-workflow.yml +++ /dev/null @@ -1,67 +0,0 @@ -name: CI - -on: - push: - -env: - DOCKER_IMAGE_NAME: ${{ secrets.DOCKER_USERNAME }}/rowlaw_docker_image - -jobs: - build-image: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - # 빌드 - - uses: actions/setup-node@v3 - with: - node-version: 16 - - run: | - yarn - yarn build - - # 도커 이미지를 만들고 도커 허브에 업로드 - - name: Build and Push Docker Image - uses: mr-smithers-excellent/docker-build-push@v6 - with: - image: ${{ env.DOCKER_IMAGE_NAME }} - tags: ${{ github.ref_name }} - registry: docker.io - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - - # https://github.com/potenday-project/308_013_FE 리포지토리의 디플로이먼트 yaml 버전 업데이트 - update-manifest: - needs: build-image - runs-on: ubuntu-latest - env: - AUTHOR_NAME: ${{ vars.AUTHOR_NAME }} - AUTHOR_EMAIL: ${{ vars.AUTHOR_EMAIL }} - MANIFEST_FILE: ${{ vars.MANIFEST_FILE }} - MANIFEST_REPOSITORY: ${{ vars.MANIFEST_REPOSITORY }} - - steps: - - name: Checkout Argocd Repository - uses: actions/checkout@v3 - with: - repository: ${{ env.MANIFEST_REPOSITORY }} - token: ${{ secrets.GITHUB_TOKEN }} - - - name: Set Image Tag - run: | - yq -i '.spec.template.spec.containers[0].image = strenv(DOCKER_IMAGE_NAME) + ":${{ github.ref_name }}" ' ${{ env.MANIFEST_FILE }} - - - name: Commit Changes - uses: EndBug/add-and-commit@v9 - with: - author_name: ${{ env.AUTHOR_NAME }} - author_email: ${{ env.AUTHOR_EMAIL }} - add: ${{ env.MANIFEST_FILE }} - message: 'Update image tag to ${{ github.ref_name }}' - - - name: Push Changes - uses: ad-m/github-push-action@v0.6.0 - with: - repository: ${{ env.MANIFEST_REPOSITORY }} - branch: main - github_token: ${{ secrets.GIT_HUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/cicd-workflow.yml b/.github/workflows/cicd-workflow.yml new file mode 100644 index 0000000..6e674c7 --- /dev/null +++ b/.github/workflows/cicd-workflow.yml @@ -0,0 +1,38 @@ +name: CICD + +on: + push: + +env: + DOCKER_IMAGE_NAME: ${{ secrets.DOCKER_USERNAME }}/rowlaw_docker_image + +jobs: + deploy: + permissions: write-all + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Install Vercel CLI + run: npm install --global vercel@latest + + - name: Pull Vercel Environment Information + run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }} + + - name: Build Project Artifacts + run: vercel build --token=${{ secrets.VERCEL_TOKEN }} + + - name: Deploy Project Artifacts to Vercel + id: preview-deployment + run: vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }} > deployment-url.txt + + - name: Extract preview url + id: extract-url + run: echo "deploymentUrl=`cat deployment-url.txt`" >> $GITHUB_OUTPUT + + - name: Comment preview url + if: ${{ github.event.issue || github.event.pull_request }} + uses: thollander/actions-comment-pull-request@v2 + with: + message: | + [링크](${{ steps.extract-url.outputs.deploymentUrl }})에서 이번 PR 결과 화면을 확인할 수 있습니다😎