Merge pull request #8 from Techeer-Hogwarts/SCRUM-152--actions #11
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
name: CI | |
on: | |
push: | |
branches: | |
- main # 메인 브렌치에 브랜치 머지 시 자동으로 실행 | |
pull_request: | |
branches: | |
- '**' # 모든 브랜치에 PR 올릴 때 실행 | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Go 1.23 | |
uses: actions/setup-go@v5 | |
with: | |
go-version: '1.23' | |
- run: go version | |
- name: Show build number | |
run: | | |
echo "Build Number: ${{ github.run_number }}" | |
- name: Show pull request number | |
if: ${{ github.event_name == 'pull_request' }} | |
run: | | |
echo "PR Number: ${{ github.event.pull_request.number }}" | |
- name: Get PR Number for Main Branch Merge | |
id: get_pr_number | |
if: github.ref == 'refs/heads/main' | |
run: | | |
PR_NUMBER=$(gh pr list --repo ${{ github.repository }} --state closed --json number,mergeCommit --jq ".[] | select(.mergeCommit.oid == \"${{ github.sha }}\") | .number") | |
echo "PR_NUMBER=${PR_NUMBER}" | |
echo "::set-output name=PR_NUMBER::$PR_NUMBER" | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set Docker Image Tag | |
run: | | |
if [ "${{ github.ref_name }}" == "main" ]; then | |
DOCKER_IMAGE_TAG="1.1.${{ github.event.pull_request.number }}" | |
else | |
DOCKER_IMAGE_TAG="0.${{ github.event.pull_request.number }}.${{ github.run_number }}" | |
fi | |
echo "Docker Image Tag: $DOCKER_IMAGE_TAG" |