diff --git a/.github/workflows/part1/issue-comment.yaml b/.github/workflows/part1/issue-comment.yaml new file mode 100644 index 000000000..4b04aa860 --- /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/issue.yaml b/.github/workflows/part1/issue.yaml new file mode 100644 index 000000000..3243dec78 --- /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 diff --git a/.github/workflows/part1/multiple_event.yaml b/.github/workflows/part1/multiple_event.yaml new file mode 100644 index 000000000..91b7e303b --- /dev/null +++ b/.github/workflows/part1/multiple_event.yaml @@ -0,0 +1,36 @@ +name: multiple-event-workflow +on: + push: + issues: + types: [opened] # 다시 공부해야하나 + 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: + multiple-event-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 }} diff --git a/.github/workflows/part1/needs.yaml b/.github/workflows/part1/needs.yaml new file mode 100644 index 000000000..45d4b9f5b --- /dev/null +++ b/.github/workflows/part1/needs.yaml @@ -0,0 +1,37 @@ +# 깃헙 액션 job 간에 종속성을 생성 +# 하나의 job이 다른 job 또는 여러 job이 완료될 때 실행되도록 사용 +# 즉 여러 job의 실행 순서를 조절 +# 테스트 job이 실행되고, 그 job이 성공할 때 배포 job이 실행되도록 구성 + +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 "job1 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" diff --git a/.github/workflows/part1/pull_request.yaml b/.github/workflows/part1/pull_request.yaml new file mode 100644 index 000000000..763010f66 --- /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 actions diff --git a/.github/workflows/part1/push.yaml b/.github/workflows/part1/push.yaml new file mode 100644 index 000000000..e592ec571 --- /dev/null +++ b/.github/workflows/part1/push.yaml @@ -0,0 +1,13 @@ +name: push-workflow test test2 +on: push # push 이벤트에 의해서 워크플로우를 트리거함 + +jobs: + push-job: + runs-on: ubuntu-latest + steps: + - name: step1 + run: echo hello world + - name: step2 + run: | + echo hello world + echo github actions diff --git a/.github/workflows/part1/workflow-dispatch.yaml b/.github/workflows/part1/workflow-dispatch.yaml new file mode 100644 index 000000000..18159d497 --- /dev/null +++ b/.github/workflows/part1/workflow-dispatch.yaml @@ -0,0 +1,33 @@ +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 }} diff --git a/.github/workflows/part2/branch-filter.yaml b/.github/workflows/part2/branch-filter.yaml new file mode 100644 index 000000000..229064353 --- /dev/null +++ b/.github/workflows/part2/branch-filter.yaml @@ -0,0 +1,11 @@ +name: branch-filter +on: + push: # push 이벤트가 + branches: ["dev"] # dev 에서 일어날 때 일어나는 워크플로우 + +jobs: + branch-filter: + runs-on: ubuntu-latest + steps: + - name: echo + run: echo hello diff --git a/.github/workflows/part2/checkout.yaml b/.github/workflows/part2/checkout.yaml new file mode 100644 index 000000000..a6dcb1c37 --- /dev/null +++ b/.github/workflows/part2/checkout.yaml @@ -0,0 +1,17 @@ +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 diff --git a/.github/workflows/part2/context.yaml b/.github/workflows/part2/context.yaml new file mode 100644 index 000000000..a23ddf04a --- /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) }}' # 컨텍스트는 객체라 toJSON으로 변환할 수 있음 + - name: check github context + run: | + echo ${{ github.repository }} + echo ${{ github.event_name }} diff --git a/.github/workflows/path-filter.yaml b/.github/workflows/path-filter.yaml new file mode 100644 index 000000000..f476e2310 --- /dev/null +++ b/.github/workflows/path-filter.yaml @@ -0,0 +1,13 @@ +name: path-filter +on: + push: + paths: + - ".github/workflows/part1/*" # paths에 변경사항이 있을 경우에만 동작하는 이벤트 + - "!.github/workflows/part1/push.yaml" + +jobs: + path-filter: + runs-on: ubuntu-latest + steps: + - name: echo hello + run: echo hello