diff --git a/.github/workflows/cicd-1.yaml b/.github/workflows/cicd-1.yaml new file mode 100644 index 000000000..5d6772c5f --- /dev/null +++ b/.github/workflows/cicd-1.yaml @@ -0,0 +1,29 @@ +name: cicd-1 +on: + pull_request: + types: [opened, synchronize, closed] + branches: [dev] + paths: + - 'my-app/**' + +jobs: + test: + if: github.event.action == 'opened' || github.event.action == 'synchronize' + runs-on: ubuntu-latest + steps: + - name: checkout + uses: actions/checkout@v4 + + image-build: + if: github.event.pull_request.merged == true #merge단계에서 실행되는 잡 , 즉 cd단계 + runs-on: ubuntu-latest + steps: + - name: checkout + uses: actions/checkout@v4 + + deploy: + runs-on: ubuntu-latest + needs: [image-build] + steps: + - name: checkout + uses: actions/checkout@v4 diff --git a/.github/workflows/part1/issue.yaml b/.github/workflows/part1/issue.yaml new file mode 100644 index 000000000..2f092ae01 --- /dev/null +++ b/.github/workflows/part1/issue.yaml @@ -0,0 +1,15 @@ +name: issue-workflow +on: + issues: + types: [opened] + +jobs: + issue-job: + runs-on: ubuntu-latest + steps: + - name: step1 + run: echo hello world + - name: step2 + run: | + echo hello world + echo github action \ No newline at end of file diff --git a/.github/workflows/part1/issue_comment.yaml b/.github/workflows/part1/issue_comment.yaml new file mode 100644 index 000000000..7d9ceb822 --- /dev/null +++ b/.github/workflows/part1/issue_comment.yaml @@ -0,0 +1,17 @@ +name: issue-comment-workflow +on: issue_comment + +jobs: + pr-comment: + if: ${{ github.event.issue.pull_request }} + runs-on: ubuntu-latest + steps: + - name: pr comment + run: echo ${{ github.event.issue.pull_request }} + + issue-comment: + if: ${{ !github.event.issue.pull_request }} + runs-on: ubuntu-latest + steps: + - name: issue comment + run: echo ${{ github.event.issue.pull_request }} diff --git a/.github/workflows/part1/multiple_event.yaml b/.github/workflows/part1/multiple_event.yaml new file mode 100644 index 000000000..6e6b89ed8 --- /dev/null +++ b/.github/workflows/part1/multiple_event.yaml @@ -0,0 +1,18 @@ +name: multiple-event-workflow +on: + push: + issues: + types: [opened] + workflow_dispatch: + + +jobs: + multiple-event-job: + runs-on: ubuntu-latest + steps: + - name: step1 + run: echo hello world + - name: step2 + run: | + echo hello world + echo github action \ No newline at end of file diff --git a/.github/workflows/part1/needs.yaml b/.github/workflows/part1/needs.yaml new file mode 100644 index 000000000..e9b0a21e3 --- /dev/null +++ b/.github/workflows/part1/needs.yaml @@ -0,0 +1,29 @@ +name: needs +on: push + +jobs: + job1: + runs-on: ubuntu-latest + steps: + - name: echo + run: echo "job1 done" + + job2: + runs-on: ubuntu-latest + needs: [job1] + steps: + - name: echo + run: echo "job2 done" + job3: + runs-on: ubuntu-latest + steps: + - name: echo + run: | + echo "job3 failed" + exit 1 + job4: + runs-on: ubuntu-latest + needs: [job3] + steps: + - name: echo + run: echo "job4 done" \ No newline at end of file diff --git a/.github/workflows/part1/pull_request.yaml b/.github/workflows/part1/pull_request.yaml new file mode 100644 index 000000000..ff8135685 --- /dev/null +++ b/.github/workflows/part1/pull_request.yaml @@ -0,0 +1,15 @@ +name: pull-request-workflow +on: + pull_request: + types: [opened] + +jobs: + pull-request-job: + runs-on: ubuntu-latest + steps: + - name: step1 + run: echo hello world + - name: step2 + run: | + echo hello world + echo github action \ No newline at end of file diff --git a/.github/workflows/part1/push.yaml b/.github/workflows/part1/push.yaml new file mode 100644 index 000000000..ef96a4a06 --- /dev/null +++ b/.github/workflows/part1/push.yaml @@ -0,0 +1,16 @@ +name: push-workflow +# 이벤트 +on: push + +# 푸시할 잡의 집합 +jobs: +# push-job이라는 이름의 job + push-job: + runs-on: ubuntu-latest2222 + steps: + - name: step1 + run: echo hello world + - name: step2 + run: | + echo hello world + echo github action \ No newline at end of file diff --git a/.github/workflows/part1/workflow_dispatch.yaml b/.github/workflows/part1/workflow_dispatch.yaml new file mode 100644 index 000000000..2b81b6f71 --- /dev/null +++ b/.github/workflows/part1/workflow_dispatch.yaml @@ -0,0 +1,34 @@ +name: workflow-dispatch +on: + workflow_dispatch: + inputs: + name: + description: 'set name' + required: true + default: 'github-actions' + type: string + environment: + description: 'set env' + required: true + default: 'dev' + type: choice + options: + - dev + - qa + - prod + + +jobs: + workflow-dispatch-job: + runs-on: ubuntu-latest + steps: + - name: step1 + run: echo hello world + - name: step2 + run: | + echo hello world + echo github action + - name: echo inputs + run: | + echo ${{ inputs.name }} + echo ${{ inputs.environment }} \ No newline at end of file diff --git a/.github/workflows/part2/artifact.yaml b/.github/workflows/part2/artifact.yaml new file mode 100644 index 000000000..4639a4c26 --- /dev/null +++ b/.github/workflows/part2/artifact.yaml @@ -0,0 +1,25 @@ +name: artifact +on: push + +jobs: + upload-artifact: + runs-on: ubuntu-latest + steps: + - name: echo + run: echo hello-world > hello.txt #텍스트 파일안에 문자열이들어가게 + - name: upload-artifact + uses: actions/upload-artifact@v3 #아티팩트 업로드 + with: + name: artifact-test #아티팩트이름 + path: ./hello.txt #아티팩트할 파일의 경로 + download-artifact: + runs-on: ubuntu-latest + needs: [upload-artifact] + steps: + - name: download-artifact + uses: actions/download-artifact@v3 + with: + name: artifact-test + path: ./ + - name: check + run: cat hello.txt \ No newline at end of file diff --git a/.github/workflows/part2/branchfilter.yaml b/.github/workflows/part2/branchfilter.yaml new file mode 100644 index 000000000..c655ee76a --- /dev/null +++ b/.github/workflows/part2/branchfilter.yaml @@ -0,0 +1,11 @@ +name: branch-filter +on: + push: + branches: ["dev-test"] + +jobs: + branch-filter: + runs-on: ubuntu-latest + steps: + - name: echo + run: echo hello \ No newline at end of file diff --git a/.github/workflows/part2/cache.yaml b/.github/workflows/part2/cache.yaml new file mode 100644 index 000000000..254459aeb --- /dev/null +++ b/.github/workflows/part2/cache.yaml @@ -0,0 +1,31 @@ +name: cache +on: + push: + paths: + - 'my-app/**' #별표 두개는 myapp 아래모든걸 포함한다는의미 + +jobs: + cache: + runs-on: ubuntu-latest + steps: + - name: checkout + uses: actions/checkout@v4 #체크아웃 하기위한 액션 + - name: setup-node + uses: actions/setup-node@v3 + with: + node-version: 18 + - name: Cache Node.js modules + uses: actions/cache@v3 + with: #with를 사용해서 path,key,restore-key 를 input값으로 전달한다 + path: ~/.npm #캐싱할 경로 + key: ${{ runner.os }}-node- + restore-keys: | + ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} + - name : Install dependencies + run: | + cd my-app + npm ci + - name: npm build + run: | + cd my-app + npm run build diff --git a/.github/workflows/part2/checkout.yaml b/.github/workflows/part2/checkout.yaml new file mode 100644 index 000000000..f36b46325 --- /dev/null +++ b/.github/workflows/part2/checkout.yaml @@ -0,0 +1,18 @@ +name: checkout +on: workflow_dispatch + +jobs: + no-checkout: + runs-on: ubuntu-latest + steps: + - name: check file list + run: cat README.md + + checkout: + runs-on: ubuntu-latest + steps: + - name: use checkout action + uses: actions/checkout@v4 + - name: check file list + run: cat README.md + \ No newline at end of file diff --git a/.github/workflows/part2/context.yaml b/.github/workflows/part2/context.yaml new file mode 100644 index 000000000..4426ed3c2 --- /dev/null +++ b/.github/workflows/part2/context.yaml @@ -0,0 +1,13 @@ +name: context +on: workflow_dispatch + +jobs: + context: + runs-on: ubuntu-latest + steps: + - name: github context + run: echo '${{ toJSON(github) }}' + - name: check github context + run: | + echo ${{ github.repository}} + echo ${{ github.event_name}} \ No newline at end of file diff --git a/.github/workflows/part2/create_repo.yaml b/.github/workflows/part2/create_repo.yaml new file mode 100644 index 000000000..45d3d4427 --- /dev/null +++ b/.github/workflows/part2/create_repo.yaml @@ -0,0 +1,29 @@ +name: create-output +on: + workflow_dispatch: + inputs: + prefix: + description: 'set repo prefix' + required: true + default: 'service' + type: choice + options: + - example + - service + name: + description: 'set repo name' + required: true + default: 'github-actions' + type: string +#gh auth login --with-token 깃헙권한 사용가능하게 +jobs: + create-repo-automation: + runs-on: ubuntu-latest + steps: + - name: gh auth login + run: | + echo ${{ secrets.PERSONAL_ACCESS_TOKEN }} | gh auth login --with-token + - name: create-repo + run: | + gh repo create woochul-action/${{ inputs.prefix }}-${{ inputs.name }} --public --add-readme + \ No newline at end of file diff --git a/.github/workflows/part2/environment.yaml b/.github/workflows/part2/environment.yaml new file mode 100644 index 000000000..376f1eb8c --- /dev/null +++ b/.github/workflows/part2/environment.yaml @@ -0,0 +1,11 @@ +name: environment +on: push + +jobs: + get-env: + runs-on: ubuntu-latest + steps: + - name: cheeck env & secret + run: | + echo ${{ vars.level }} + echo ${{ secrets.key }} \ No newline at end of file diff --git a/.github/workflows/part2/issue_notify.yaml b/.github/workflows/part2/issue_notify.yaml new file mode 100644 index 000000000..4e42480d4 --- /dev/null +++ b/.github/workflows/part2/issue_notify.yaml @@ -0,0 +1,28 @@ +name: issue-notify +on: + issues: + types: [opened] + +jobs: + get-keyword: + runs-on: ubuntu-latest + outputs: + level: ${{ steps.get-keyword.outputs.level }} + steps: + - name: checkout + uses: actions/checkout@v4 #checkout 액션을 사용하면 github repo코드를 github job으로 가져올수있음 + - name: get keyword + id: get-keyword + run: | + echo level=Undefined >> $GITHUB_OUTPUT + + keywords=$(cat keyword-list.txt) + for keyword in $keywords; do + if [[ "${{ github.event.issue.title }}" =~ "$keyword" ]]; then + echo level=$keyword >> $GITHUB_OUTPUT + + fi + done + - name: get output + run: | + echo ${{ steps.get-keyword.outputs.level }} \ No newline at end of file diff --git a/.github/workflows/part2/output.yaml b/.github/workflows/part2/output.yaml new file mode 100644 index 000000000..36c797cfb --- /dev/null +++ b/.github/workflows/part2/output.yaml @@ -0,0 +1,23 @@ +name: output +on: push + +jobs: + create-output: + runs-on: ubuntu-latest + outputs: + test: ${{ steps:check-out.outputs.test }} + steps: + - name: echo output + id: chec-output + run: | + echo "test=hello" >> $GITHUB_OUTPUT + - name: check output + run: | + echo ${{ steps.check-output.outputs.test }} + + get-output: + needs: [create-output] + runs-on: ubuntu-latest + steps: + - name: get output + run: echo ${{ needs.create-output.outputs.test }} diff --git a/.github/workflows/part2/pathfilter.yaml b/.github/workflows/part2/pathfilter.yaml new file mode 100644 index 000000000..fb1b2b9b7 --- /dev/null +++ b/.github/workflows/part2/pathfilter.yaml @@ -0,0 +1,12 @@ +name: path-filter +on: + push: + paths: + - '.github/workflows/part1/*' + - '!.github/workflows/part1/push.yaml' +jobs: + path-filter: + runs-on: ubuntu-latest + steps: + - name: echo hello + run: echo hello \ No newline at end of file diff --git a/.github/workflows/part2/tag_filter.yaml b/.github/workflows/part2/tag_filter.yaml new file mode 100644 index 000000000..832468500 --- /dev/null +++ b/.github/workflows/part2/tag_filter.yaml @@ -0,0 +1,12 @@ +name: tag_filter +on: + push: + tags: + - 'v[0-9]+.[0-9].[0-9]+' #v1.0.0 or v2.2.2 이런식으로 만 푸시해야 트리거됨 + +jobs: + tag_filter: + runs-on: ubuntu-latest + steps: + - name: echo + run: echo hello \ No newline at end of file diff --git a/.github/workflows/part2/var-1.yaml b/.github/workflows/part2/var-1.yaml new file mode 100644 index 000000000..9bc593176 --- /dev/null +++ b/.github/workflows/part2/var-1.yaml @@ -0,0 +1,39 @@ +name: var-1 +on: push + +env: + level: workflow + +#workflow level에서 env생성 +jobs: + get-env-1: + runs-on: ubuntu-latest + steps: + - name: check env + run: echo "LEVEL ${{ env.level }}" +#job level에서 env생성 + get-env-2: + runs-on: ubuntu-latest + env: + level: job + steps: + - name: check env + run: echo "LEVEL ${{ env.level }}" +#step level에서 env생성 + get-env-3: + runs-on: ubuntu-latest + env: + level: job + steps: + - name: check env + run: echo "LEVEL ${{ env.level }}" + env: + level: step + + get-env: + runs-on: ubuntu-latest + steps: + - name: check env + run: echo "level=job" >> $GITHUB_ENV + - name: check env + run: echo "LEVEL ${{ env.level }}" \ No newline at end of file diff --git a/.github/workflows/part2/var-2.yaml b/.github/workflows/part2/var-2.yaml new file mode 100644 index 000000000..09491ce8c --- /dev/null +++ b/.github/workflows/part2/var-2.yaml @@ -0,0 +1,9 @@ +name: var-2 +on: push +#레파지토리 setting에들어가서 secrets and variables에서variable 추가하면 이렇게 바로쓸수있ㅇ므 +jobs: + get-var: + runs-on: ubuntu-latest + steps: + - name: get var + run: echo ${{ vars.level }} \ No newline at end of file diff --git a/.gitmessage.txt b/.gitmessage.txt new file mode 100644 index 000000000..c9822699b --- /dev/null +++ b/.gitmessage.txt @@ -0,0 +1,38 @@ +# my commit message template +# 본문과 푸터는 선택 사항입니다. +################## +# type: Subject (아래에 작성) + +# Body(아래에 작성) + +# Footer(아래에 작성) +################## +# feat: 새로운 기능 추가 +# fix: 버그 수정 +# docs: 문서 수정 +# style: 코드 포맷팅, 세미콜론 누락, 코드 변경이 없는 경우 +# refactor: 코드 리팩토링 +# test: 테스트 코드, 리팩토링 테스트 코드 추가 +# chore: 빌드 업무 수정, 패키지 매니저 수정, production code와 무관한 부분들 (.gitignore, build.gradle 같은) +# comment: 주석 추가 및 변경 +# remove: 파일, 폴더 삭제 +# rename: 파일, 폴더명 수정 +################## +# 영어로 Subject 작성 시 +# Add : 추가 +# Remove : 삭제 +# Simplify : 단순화 +# Update : 보완 +# Implement : 구현 +# Prevent : 방지 +# Move : 이동 +# Rename : 이름 변경 +################## +# 예시 +# feat: "로그인 기능 구현" + +# 로그인 시 JWT 발급 + +# Resolves: #111 +# Ref: #122 +# related to: #30, #50 \ No newline at end of file diff --git a/keyword-list.txt b/keyword-list.txt new file mode 100644 index 000000000..0a50b8fb0 --- /dev/null +++ b/keyword-list.txt @@ -0,0 +1,2 @@ +critical +nomal \ No newline at end of file diff --git a/my-app/src/App.js b/my-app/src/App.js index 725bc9db5..a5105428d 100644 --- a/my-app/src/App.js +++ b/my-app/src/App.js @@ -15,7 +15,7 @@ function App() { target="_blank" rel="noopener noreferrer" > - Learn GithubAction cicd + Learn GithubAction cicd1 test