diff --git a/.github/workflows/cicd-1.yaml b/.github/workflows/cicd-1.yaml new file mode 100644 index 000000000..5031957ea --- /dev/null +++ b/.github/workflows/cicd-1.yaml @@ -0,0 +1,28 @@ +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 + 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 \ No newline at end of file diff --git a/.github/workflows/part1/branch_filter.yaml b/.github/workflows/part1/branch_filter.yaml new file mode 100644 index 000000000..3da8fd450 --- /dev/null +++ b/.github/workflows/part1/branch_filter.yaml @@ -0,0 +1,10 @@ +name: branch-filter +on: + push: + branches: ["dev"] +jobs: + branch-filter: + runs-on: ubuntu-latest + steps: + - name: echo + run: echo hello \ No newline at end of file diff --git a/.github/workflows/part1/issue.yaml b/.github/workflows/part1/issue.yaml new file mode 100644 index 000000000..f243d9a9b --- /dev/null +++ b/.github/workflows/part1/issue.yaml @@ -0,0 +1,15 @@ +name: issue-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/issue_comment.yaml b/.github/workflows/part1/issue_comment.yaml new file mode 100644 index 000000000..5514f7256 --- /dev/null +++ b/.github/workflows/part1/issue_comment.yaml @@ -0,0 +1,16 @@ +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 }} \ No newline at end of file diff --git a/.github/workflows/part1/multiple_event.yaml b/.github/workflows/part1/multiple_event.yaml new file mode 100644 index 000000000..f2caf2094 --- /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..eba119ecb --- /dev/null +++ b/.github/workflows/part1/needs.yaml @@ -0,0 +1,28 @@ +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" diff --git a/.github/workflows/part1/pull_request.yaml b/.github/workflows/part1/pull_request.yaml new file mode 100644 index 000000000..f69c3c8cf --- /dev/null +++ b/.github/workflows/part1/pull_request.yaml @@ -0,0 +1,15 @@ +name: pull-request-workflow 1 +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..3cfb4061b --- /dev/null +++ b/.github/workflows/part1/push.yaml @@ -0,0 +1,13 @@ +name: push-workflow +on: push + +jobs: + push-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/workflow_diapatch.yaml b/.github/workflows/part1/workflow_diapatch.yaml new file mode 100644 index 000000000..d648ff06d --- /dev/null +++ b/.github/workflows/part1/workflow_diapatch.yaml @@ -0,0 +1,32 @@ +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/artifact.yaml b/.github/workflows/part2/artifact.yaml new file mode 100644 index 000000000..d6bab6dd8 --- /dev/null +++ b/.github/workflows/part2/artifact.yaml @@ -0,0 +1,28 @@ +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@v4 + with: + name: artifact-test + path: ./hello.txt + + download-artifact: + runs-on: ubuntu-latest + needs: [upload-artifact] + steps: + - name: download artifact + uses: actions/download-artifact@v4 + with: + name: artifact-test + path: ./ + + - name: check + run: cat hello.txt \ 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..e1253cb20 --- /dev/null +++ b/.github/workflows/part2/cache.yaml @@ -0,0 +1,30 @@ +name: cache +on: + push: + paths: + - 'my-app/**' +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: + path: ~/.npm + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node- + - name: Install dependencies + run: | + cd my-app + npm ci + - name: npm build + run: | + cd my-app + npm run build \ No newline at end of file diff --git a/.github/workflows/part2/checkout.yaml b/.github/workflows/part2/checkout.yaml new file mode 100644 index 000000000..7cfda83ee --- /dev/null +++ b/.github/workflows/part2/checkout.yaml @@ -0,0 +1,16 @@ +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..9a642a8d0 --- /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/environment.yaml b/.github/workflows/part2/environment.yaml new file mode 100644 index 000000000..39e5ead53 --- /dev/null +++ b/.github/workflows/part2/environment.yaml @@ -0,0 +1,19 @@ +name: environment +on: push + +jobs: + get-env: + runs-on: ubuntu-latest + steps: + - name: check env & secret + run: | + echo ${{ secrets.level }} + echo ${{ vars.level }} + get-env-dev: + runs-on: ubuntu-latest + environment: dev + steps: + - name: check env & secret + run: | + echo ${{ secrets.level }} + echo ${{ vars.level }} \ No newline at end of file diff --git a/.github/workflows/part2/if-1.yaml b/.github/workflows/part2/if-1.yaml new file mode 100644 index 000000000..a295559a4 --- /dev/null +++ b/.github/workflows/part2/if-1.yaml @@ -0,0 +1,28 @@ +name: if-1 +on: + push: + workflow_dispatch: + + +jobs: + job1: + runs-on: ubuntu-latest + if: github.event_name == 'push' + steps: + - name: get event name + run: echo ${{ github.event_name }} + job2: + runs-on: ubuntu-latest + if: github.event_name != 'push' + steps: + - name: get event name + run: echo ${{ github.event_name }} + job3: + runs-on: ubuntu-latest + steps: + - name: get event name + if: github.event_name == 'push' + run: echo "PUSH" + - name: get event name + if: github.event_name != 'push' + run: echo "WORKFLOW_DISPATCH" diff --git a/.github/workflows/part2/if-2.yaml b/.github/workflows/part2/if-2.yaml new file mode 100644 index 000000000..d21bbf6be --- /dev/null +++ b/.github/workflows/part2/if-2.yaml @@ -0,0 +1,22 @@ +name: if-1\2 +on: + push: + workflow_dispatch: + + +jobs: + job1: + runs-on: ubuntu-latest + steps: + - name: exit1 + run: exit1 + - name: echo + if: always() + run: echo hello + job2: + needs: [job1] + runs-on: ubuntu-latest + if: always() + steps: + - name: echo + run: echo hello \ No newline at end of file diff --git a/.github/workflows/part2/matrix.yaml b/.github/workflows/part2/matrix.yaml new file mode 100644 index 000000000..c2885b07e --- /dev/null +++ b/.github/workflows/part2/matrix.yaml @@ -0,0 +1,15 @@ +name: matrix +on: push + +jobs: + get-matrix: + strategy: + matrix: + os: [windows-latest, ubuntu-latest] + version: [12,14] + runs-on: ${{ matrix.os }} + steps: + - name: check matrix + run: | + echo ${{ matrix.os }} + echo ${{ matrix.version }} diff --git a/.github/workflows/part2/output.yaml b/.github/workflows/part2/output.yaml new file mode 100644 index 000000000..cbd0afd02 --- /dev/null +++ b/.github/workflows/part2/output.yaml @@ -0,0 +1,22 @@ +name: output +on: push +jobs: + create-output: + runs-on: ubuntu-latest + outputs: + test: ${{ steps.check-output.outputs.test }} + steps: + - name: echo output + id: check-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 ${{ steps.create-output.outputs.test }} + diff --git a/.github/workflows/part2/path_filter.yaml b/.github/workflows/part2/path_filter.yaml new file mode 100644 index 000000000..e00e0e03b --- /dev/null +++ b/.github/workflows/part2/path_filter.yaml @@ -0,0 +1,12 @@ +name: path_filter +on: + push: + paths: + - '!.github/workflows/part1/push.yaml' + - '.github/workflows/part1/*' +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/secrests.yaml b/.github/workflows/part2/secrests.yaml new file mode 100644 index 000000000..57e40613d --- /dev/null +++ b/.github/workflows/part2/secrests.yaml @@ -0,0 +1,9 @@ +name: secrets +on: push + +jobs: + get-secrets: + runs-on: ubuntu-latest + steps: + - name: get-secrets + run: echo ${{ secrets.level }} \ No newline at end of file diff --git a/.github/workflows/part2/string-function.yaml b/.github/workflows/part2/string-function.yaml new file mode 100644 index 000000000..edec74ce6 --- /dev/null +++ b/.github/workflows/part2/string-function.yaml @@ -0,0 +1,25 @@ +name: string-function +on: push +jobs: + string-function: + runs-on: ubuntu-latest + steps: + - name: startswith + if: startsWith('github actions', 'git') + run: echo "git" + - name: startsswith + if: startsWith('github actions', 'test') + run: echo "test" + - name: endswith + if: endsWith('github actions', 'ions') + run: echo "ions" + - name: endswith + if: endsWith('github actions', 'test') + run: echo "test" + + - name: contains + if: contains('github actions', 'act') + run: echo "contains act" + - name: contains + if: contains('github, actions', 'git') + run: echo "contains git" \ 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..7891e98fa --- /dev/null +++ b/.github/workflows/part2/tag_filter.yaml @@ -0,0 +1,11 @@ +name: tag-filter +on: + push: + tags: + - 'v[0-9]+.[0-9].[0-9]+' +jobs: + tag-filter: + runs-on: ubuntu-latest + steps: + - name: echo hello + run: echo hello \ No newline at end of file diff --git a/.github/workflows/part2/timeout.yaml b/.github/workflows/part2/timeout.yaml new file mode 100644 index 000000000..f8492bf20 --- /dev/null +++ b/.github/workflows/part2/timeout.yaml @@ -0,0 +1,19 @@ +name: timeout +on: push + +jobs: + timeout: + runs-on: ubuntu-latest + timeout-minutes: 2 + steps: + - name: loop + run: | + count=0 + while true; do + echo "seconds: $count" + count=$((count+1)) + sleep 1 + done + timeout-minutes: 1 + - 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..f77d381a9 --- /dev/null +++ b/.github/workflows/part2/var-1.yaml @@ -0,0 +1,38 @@ +name: var-1 +on: push + +env: + level: workflow + +jobs: + get-env-1: + runs-on: ubuntu-latest + steps: + - name: check env + run: echo "LEVEL ${{ env.level }}" + + get-env-2: + runs-on: ubuntu-latest + env: + level: job + steps: + - name: check env + run: echo "LEVEL ${{ env.level }}" + + 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: create 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..2face9e83 --- /dev/null +++ b/.github/workflows/part2/var-2.yaml @@ -0,0 +1,9 @@ +name: var-2 +on: push + +jobs: + get-var: + runs-on: ubuntu-latest + steps: + - name: get var + run: echo ${{ vars.level }} \ No newline at end of file diff --git a/.github/workflows/part3/create_repo.yaml b/.github/workflows/part3/create_repo.yaml new file mode 100644 index 000000000..9c45b3ac6 --- /dev/null +++ b/.github/workflows/part3/create_repo.yaml @@ -0,0 +1,50 @@ +name: create-repo +on: + workflow_dispatch: + inputs: + prefix: + description: 'set repo prefix' + required: true + type: choice + options: + - example + - service + name: + description: 'set repo name' + required: true + default: 'github-actions' + type: string +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 + id: create-repo + run: | + gh repo create sini-aciton/${{ inputs.prefix }}-${{ inputs.name }} --public --add-readme + - name: slack + if: always() + uses: slackapi/slack-github-action@v1.24.0 + with: + payload: | + { + "attachments": [ + { + "pretext": "create repo result", + "color": "28a745", + "fields": [ + { + "title": "create repo result ${{ steps.create-repo.outcome }}", + "short": true, + "value": "${{ inputs.prefix }}-${{ inputs.name }}" + } + ] + } + ] + } + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK \ No newline at end of file diff --git a/.github/workflows/part3/issue_notify.yaml b/.github/workflows/part3/issue_notify.yaml new file mode 100644 index 000000000..04a91cfe7 --- /dev/null +++ b/.github/workflows/part3/issue_notify.yaml @@ -0,0 +1,54 @@ +name: create-repo +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 + - 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 }} + slack: + needs: [get-keyword] + if: needs.get-keyword.outputs.level != 'Undefined' + runs-on: ubuntu-latest + environment: ${{ needs.get-keyword.outputs.level}} + steps: + - name: slack + uses: slackapi/slack-github-action@v1.24.0 + with: + payload: | + { + "attachments": [ + { + "pretext": "issue alert message", + "color": "28a745", + "fields": [ + { + "title": "create repo result ${{ needs.get-keyword.outputs.level }}", + "short": true, + "value": "issue url : ${{ github.event.issue.html_url }}" + } + ] + } + ] + } + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK \ No newline at end of file diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 000000000..c3f502a19 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# 디폴트 무시된 파일 +/shelf/ +/workspace.xml +# 에디터 기반 HTTP 클라이언트 요청 +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/github-actions.iml b/.idea/github-actions.iml new file mode 100644 index 000000000..d6ebd4805 --- /dev/null +++ b/.idea/github-actions.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 000000000..47478b911 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 000000000..e152f1a5c --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 000000000..35eb1ddfb --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/keyword-list.txt b/keyword-list.txt new file mode 100644 index 000000000..503fe1db0 --- /dev/null +++ b/keyword-list.txt @@ -0,0 +1,2 @@ +critical +normal \ No newline at end of file diff --git a/my-app/src/App.js b/my-app/src/App.js index 725bc9db5..7cbc32dbd 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 cicd test2