์๊ฐ
์ด ๊ฐ์ด๋์์๋ ํจํค์ง๋ ๋ณตํฉ ์์
์ ๋ง๋ค๊ณ ์ฌ์ฉํ๋ ๋ฐ ํ์ํ ๊ธฐ๋ณธ ๊ตฌ์ฑ ์์์ ๋ํด ์์๋ด
๋๋ค. ์์
์ ํจํค์งํ๋ ๋ฐ ํ์ํ ๊ตฌ์ฑ ์์์ ๊ฐ์ด๋์ ์ด์ ์ ๋ง์ถ๊ธฐ ์ํด ์์
์ฝ๋์ ๊ธฐ๋ฅ์ ์ต์ํ๋ฉ๋๋ค. ์์
์ โHello Worldโ๋ฅผ ์ถ๋ ฅํ ๋ค์ โGoodbyeโ๋ฅผ ์ถ๋ ฅํ๊ฑฐ๋ ์ฌ์ฉ์ ์ง์ ์ด๋ฆ์ ์ ๊ณตํ๋ ๊ฒฝ์ฐ โHello [์ธ์ฌํ ์ฌ๋]โ์ ์ถ๋ ฅํ ๋ค์ โGoodbyeโ๋ฅผ ์ถ๋ ฅํฉ๋๋ค. ์ด ์์
์ ๋ํ ๋์๋ฅผ random-number
์ถ๋ ฅ ๋ณ์์ ๋งคํํ๊ณ goodbye.sh
๋ผ๋ ์คํฌ๋ฆฝํธ๋ฅผ ์คํํฉ๋๋ค.
์ด ํ๋ก์ ํธ๋ฅผ ์๋ฃํ ํ์๋ ๊ณ ์ ํ ๋ณตํฉ ์์ ์ ๋น๋ํ๊ณ ์ํฌํ๋ก์์ ํ ์คํธํ๋ ๋ฐฉ๋ฒ์ ์ดํดํด์ผ ํฉ๋๋ค.
๊ฒฝ๊ณ
์ํฌํ๋ก์ ์์ ์ ๋ง๋ค ๋๋ ์ฝ๋๊ฐ ๊ณต๊ฒฉ์์ ์ ๋ขฐํ ์ ์๋ ์ ๋ ฅ์ ์คํํ ์ ์๋์ง ํญ์ ๊ณ ๋ คํด์ผ ํฉ๋๋ค. ํน์ ์ปจํ ์คํธ๋ ๊ณต๊ฒฉ์๊ฐ ์์ ์ ์ ์ฑ ์ฝํ ์ธ ๋ฅผ ์ฝ์ ํ ์ ์์ผ๋ฏ๋ก ์ ๋ขฐํ ์ ์๋ ์ ๋ ฅ์ผ๋ก ์ทจ๊ธํด์ผ ํฉ๋๋ค. ์์ธํ ๋ด์ฉ์ ๋ณด์ ์ฌ์ฉ ์ฐธ์กฐ์(๋ฅผ) ์ฐธ์กฐํ์ธ์.
๋ณตํฉ ์์ ๋ฐ ์ฌ์ฌ์ฉ ๊ฐ๋ฅํ ์ํฌํ๋ก
๋ณตํฉ ์์ ์ ์ฌ์ฉํ๋ฉด ์ผ๋ จ์ ์ํฌํ๋ก ์์ ๋จ๊ณ๋ฅผ ๋จ์ผ ์์ ์ผ๋ก ์์งํ ๋ค์, ์ฌ๋ฌ ์ํฌํ๋ก์์ ๋จ์ผ ์์ ๋จ๊ณ๋ก ์คํํ ์ ์์ต๋๋ค. ์ฌ์ฌ์ฉ ๊ฐ๋ฅํ ์ํฌํ๋ก๋ ๋ค๋ฅธ ์ํฌํ๋ก ๋ด์์ ์ ์ฒด ์ํฌํ๋ก๋ฅผ ์คํํ ์ ์๋๋ก ํ์ฌ ์ค๋ณต์ ๋ฐฉ์งํ๋ ๋ ๋ค๋ฅธ ๋ฐฉ๋ฒ์ ์ ๊ณตํฉ๋๋ค. ์์ธํ ๋ด์ฉ์ ์ฌ์ฌ์ฉ ๊ฐ๋ฅํ ์ํฌํ๋ก์(๋ฅผ) ์ฐธ์กฐํ์ธ์.
ํ์ ์กฐ๊ฑด
์ฐธ๊ณ ํญ๋ชฉ
์ด ์์ ์์๋ ๋ณ๋์ ๋ฆฌํฌ์งํ ๋ฆฌ ๋ด์์ ๋ณตํฉ ์์ ์ ๋ง๋๋ ๋ฐฉ๋ฒ์ ์ค๋ช ํฉ๋๋ค. ๊ทธ๋ฌ๋ ๋์ผํ ๋ฆฌํฌ์งํ ๋ฆฌ ๋ด์์ ๋ณตํฉ ์์ ์ ๋ง๋ค ์ ์์ต๋๋ค. ์์ธํ ๋ด์ฉ์ ๋ณตํฉ ์์ ๋ง๋ค๊ธฐ์(๋ฅผ) ์ฐธ์กฐํ์ธ์.
์์ํ๊ธฐ ์ ์ GitHub์์ ๋ฆฌํฌ์งํ ๋ฆฌ๋ฅผ ์์ฑํฉ๋๋ค.
-
GitHub์ ์ ํผ๋ธ๋ฆญ ๋ฆฌํฌ์งํ ๋ฆฌ๋ฅผ ๋ง๋ญ๋๋ค. ๋ฆฌํฌ์งํ ๋ฆฌ ์ด๋ฆ์ ์ ํํ๊ฑฐ๋ ๋ค์
hello-world-composite-action
์์ ๋ฅผ ์ฌ์ฉํ ์ ์์ต๋๋ค. ํ๋ก์ ํธ๊ฐ GitHub์ ํธ์๋ ํ ํด๋น ํ์ผ์ ์ถ๊ฐํ ์ ์์ต๋๋ค. ์์ธํ ๋ด์ฉ์ ์ ๋ฆฌํฌ์งํ ๋ฆฌ ๋ง๋ค๊ธฐ์(๋ฅผ) ์ฐธ์กฐํ์ธ์. -
์ปดํจํฐ์ ๋ฆฌํฌ์งํ ๋ฆฌ๋ฅผ ๋ณต์ ํฉ๋๋ค. ์์ธํ ๋ด์ฉ์ ๋ฆฌํฌ์งํ ๋ฆฌ ๋ณต์ ์(๋ฅผ) ์ฐธ์กฐํ์ธ์.
-
ํฐ๋ฏธ๋์์ ๋๋ ํฐ๋ฆฌ๋ฅผ ์ ๋ฆฌํฌ์งํ ๋ฆฌ๋ก ๋ณ๊ฒฝํฉ๋๋ค.
Shell cd hello-world-composite-action
cd hello-world-composite-action
-
hello-world-composite-action
๋ฆฌํฌ์งํ ๋ฆฌ์์ ๋ค์ ์์ ์ฝ๋๋กgoodbye.sh
๋ผ๋ ์ ํ์ผ์ ๋ง๋์ธ์.Shell echo "echo Goodbye" > goodbye.sh
echo "echo Goodbye" > goodbye.sh
-
ํฐ๋ฏธ๋์์
goodbye.sh
์คํ ํ์ผ์ ๋ง๋ญ๋๋ค.Shell chmod +x goodbye.sh
chmod +x goodbye.sh
chmod +x goodbye.sh
chmod +x goodbye.sh
git add --chmod=+x -- goodbye.sh
git add --chmod=+x -- goodbye.sh
-
ํฐ๋ฏธ๋์์
goodbye.sh
ํ์ผ์ ์ฒดํฌ ์ธํฉ๋๋ค.Shell git add goodbye.sh git commit -m "Add goodbye script" git push
git add goodbye.sh git commit -m "Add goodbye script" git push
git add goodbye.sh git commit -m "Add goodbye script" git push
git add goodbye.sh
git commit -m "Add goodbye script"
git push
git commit -m "Add goodbye script" git push
git commit -m "Add goodbye script"
git push
์์ ๋ฉํ๋ฐ์ดํฐ ํ์ผ ๋ง๋ค๊ธฐ
-
hello-world-composite-action
๋ฆฌํฌ์งํ ๋ฆฌ์์action.yml
๋ผ๋ ์ ํ์ผ์ ๋ง๋ค๊ณ ๋ค์ ์์ ์ฝ๋๋ฅผ ์ถ๊ฐํฉ๋๋ค. ์ด ๊ตฌ๋ฌธ์ ๋ํ ์์ธํ ๋ด์ฉ์ ๋ฉํ๋ฐ์ดํฐ ๊ตฌ๋ฌธ ์ฐธ์กฐ์(๋ฅผ) ์ฐธ์กฐํ์ธ์.YAML name: 'Hello World' description: 'Greet someone' inputs: who-to-greet: # id of input description: 'Who to greet' required: true default: 'World' outputs: random-number: description: "Random number" value: ${{ steps.random-number-generator.outputs.random-number }} runs: using: "composite" steps: - name: Set Greeting run: echo "Hello $INPUT_WHO_TO_GREET." shell: bash env: INPUT_WHO_TO_GREET: ${{ inputs.who-to-greet }} - name: Random Number Generator id: random-number-generator run: echo "random-number=$(echo $RANDOM)" >> $GITHUB_OUTPUT shell: bash - name: Set GitHub Path run: echo "$GITHUB_ACTION_PATH" >> $GITHUB_PATH shell: bash env: GITHUB_ACTION_PATH: ${{ github.action_path }} - name: Run goodbye.sh run: goodbye.sh shell: bash
name: 'Hello World' description: 'Greet someone' inputs: who-to-greet: # id of input description: 'Who to greet' required: true default: 'World' outputs: random-number: description: "Random number" value: ${{ steps.random-number-generator.outputs.random-number }} runs: using: "composite" steps: - name: Set Greeting run: echo "Hello $INPUT_WHO_TO_GREET." shell: bash env: INPUT_WHO_TO_GREET: ${{ inputs.who-to-greet }} - name: Random Number Generator id: random-number-generator run: echo "random-number=$(echo $RANDOM)" >> $GITHUB_OUTPUT shell: bash - name: Set GitHub Path run: echo "$GITHUB_ACTION_PATH" >> $GITHUB_PATH shell: bash env: GITHUB_ACTION_PATH: ${{ github.action_path }} - name: Run goodbye.sh run: goodbye.sh shell: bash
์ด ํ์ผ์
who-to-greet
์ ๋ ฅ์ ์ ์ํ๊ณ , ์์ ์์ฑ๋ ์ซ์๋ฅผrandom-number
์ถ๋ ฅ ๋ณ์์ ๋งคํํ๋ฉฐ, ์คํ๊ธฐ ์์คํ ๊ฒฝ๋ก์ ๋์์ ๊ฒฝ๋ก๋ฅผ ์ถ๊ฐ(์คํ ์คgoodbye.sh
์คํฌ๋ฆฝํธ๋ฅผ ์ฐพ๊ธฐ ์ํด)ํ๊ณ ,goodbye.sh
์คํฌ๋ฆฝํธ๋ฅผ ์คํํฉ๋๋ค.์ถ๋ ฅ ๊ด๋ฆฌ์ ๋ํ ์์ธํ ์ ๋ณด๋ ๋ฉํ๋ฐ์ดํฐ ๊ตฌ๋ฌธ ์ฐธ์กฐ์(๋ฅผ) ์ฐธ์กฐํ์ธ์.
github.action_path
์ฌ์ฉ ๋ฐฉ๋ฒ์ ๋ํ ์์ธํ ๋ด์ฉ์ ์ปจํ ์คํธ ์ฐธ์กฐ์(๋ฅผ) ์ฐธ์กฐํ์ธ์. -
ํฐ๋ฏธ๋์์
action.yml
ํ์ผ์ ์ฒดํฌ ์ธํฉ๋๋ค.Shell git add action.yml git commit -m "Add action" git push
git add action.yml git commit -m "Add action" git push
-
ํฐ๋ฏธ๋์์ ํ๊ทธ๋ฅผ ์ถ๊ฐํฉ๋๋ค. ์ด ์์ ์์๋
v1
์ด๋ผ๋ ํ๊ทธ๋ฅผ ์ฌ์ฉํฉ๋๋ค. ์์ธํ ๋ด์ฉ์ ์ฌ์ฉ์ ์ง์ ์์ ์ ๋ณด์(๋ฅผ) ์ฐธ์กฐํ์ธ์.Shell git tag -a -m "Description of this release" v1 git push --follow-tags
git tag -a -m "Description of this release" v1 git push --follow-tags
์ํฌํ๋ก์์ ์์ ํ ์คํธ
๋ค์ ์ํฌํ๋ก ์ฝ๋๋ ๋ณตํฉ ์์ ๋ง๋ค๊ธฐ์์ ์ํํ ์๋ฃ๋ hello world ์์ ์ ์ฌ์ฉํฉ๋๋ค.
์ํฌํ๋ก ์ฝ๋๋ฅผ ๋ค๋ฅธ ๋ฆฌํฌ์งํ ๋ฆฌ์ .github/workflows/main.yml
ํ์ผ์ ๋ณต์ฌํ์ฌ OWNER
๋ฐ SHA
๋ฅผ ๊ฐ๊ฐ ๋ฆฌํฌ์งํ ๋ฆฌ ์์ ์์ ์ฌ์ฉํ ์ปค๋ฐ์ SHA๋ก ๋ฐ๊ฟ๋๋ค. who-to-greet
์
๋ ฅ์ ์์ ์ ์ด๋ฆ์ผ๋ก ๋ฐ๊ฟ ์๋ ์์ต๋๋ค.
on: [push] jobs: hello_world_job: runs-on: ubuntu-latest name: A job to say hello steps: - uses: actions/checkout@v4 - id: foo uses: OWNER/hello-world-composite-action@SHA with: who-to-greet: 'Mona the Octocat' - run: echo random-number "$RANDOM_NUMBER" shell: bash env: RANDOM_NUMBER: ${{ steps.foo.outputs.random-number }}
on: [push]
jobs:
hello_world_job:
runs-on: ubuntu-latest
name: A job to say hello
steps:
- uses: actions/checkout@v4
- id: foo
uses: OWNER/hello-world-composite-action@SHA
with:
who-to-greet: 'Mona the Octocat'
- run: echo random-number "$RANDOM_NUMBER"
shell: bash
env:
RANDOM_NUMBER: ${{ steps.foo.outputs.random-number }}
๋ฆฌํฌ์งํ ๋ฆฌ์์ ์์ ํญ์ ํด๋ฆญํ๊ณ ์ต์ ์ํฌํ๋ก ์คํ์ ์ ํํฉ๋๋ค. ์ถ๋ ฅ์๋ โHello Mona the Octocatโ, โGoodbyeโ ์คํฌ๋ฆฝํธ์ ๊ฒฐ๊ณผ์ ๋์๊ฐ ํฌํจ๋์ด์ผ ํฉ๋๋ค.
๋์ผํ ๋ฆฌํฌ์งํ ๋ฆฌ ๋ด์์ ๋ณตํฉ ์์ ๋ง๋ค๊ธฐ
-
hello-world-composite-action
๋ผ๋ ์ ํ์ ํด๋๋ฅผ ๋ง๋ญ๋๋ค. ์ด ํด๋๋ ๋ฆฌํฌ์งํ ๋ฆฌ ๋ด์ ๋ชจ๋ ํ์ ํด๋์ ๋ฐฐ์นํ ์ ์์ต๋๋ค. ํ์ง๋ง ์กฐ์ง์ ๋ ์ฝ๊ฒ ์ ๋ฆฌํ๊ธฐ ์ํด์๋.github/actions
ํ์ ํด๋์ ๋ฐฐ์นํ๋ ๊ฒ์ด ๋ ์ข์ต๋๋ค. -
hello-world-composite-action
ํด๋์์goodbye.sh
์คํฌ๋ฆฝํธ๋ฅผ ๋ง๋ค๊ธฐ ์ํด ๋์ผํ ๋จ๊ณ๋ฅผ ์ํํฉ๋๋ค.Shell echo "echo Goodbye" > goodbye.sh
echo "echo Goodbye" > goodbye.sh
Shell chmod +x goodbye.sh
chmod +x goodbye.sh
chmod +x goodbye.sh
chmod +x goodbye.sh
git add --chmod=+x -- goodbye.sh
git add --chmod=+x -- goodbye.sh
git add goodbye.sh git commit -m "Add goodbye script" git push
git add goodbye.sh
git commit -m "Add goodbye script"
git push
git add goodbye.sh git commit -m "Add goodbye script" git push
git add goodbye.sh
git commit -m "Add goodbye script"
git push
git commit -m "Add goodbye script" git push
git commit -m "Add goodbye script"
git push
hello-world-composite-action
ํด๋์ ๋ณตํฉ ์์ ๋ง๋ค๊ธฐ์ ๋จ๊ณ์ ๋ฐ๋ผaction.yml
ํ์ผ์ ๋ง๋ญ๋๋ค.- ์ด ์์
์ ์งํํ ๋๋
uses
ํค์ ๋ณตํฉ ์์ ์action.yml
ํ์ผ์ด ์์นํ ํด๋์ ์๋ ๊ฒฝ๋ก๋ฅผ ์ง์ ํฉ๋๋ค. ์๋ ์์ ์์๋.github/actions/hello-world-composite-action
ํด๋์ ์์ ์ด ์๋ค๊ณ ๊ฐ์ ํฉ๋๋ค.
on: [push] jobs: hello_world_job: runs-on: ubuntu-latest name: A job to say hello steps: - uses: actions/checkout@v4 - id: foo uses: ./.github/actions/hello-world-composite-action with: who-to-greet: 'Mona the Octocat' - run: echo random-number "$RANDOM_NUMBER" shell: bash env: RANDOM_NUMBER: ${{ steps.foo.outputs.random-number }}
on: [push]
jobs:
hello_world_job:
runs-on: ubuntu-latest
name: A job to say hello
steps:
- uses: actions/checkout@v4
- id: foo
uses: ./.github/actions/hello-world-composite-action
with:
who-to-greet: 'Mona the Octocat'
- run: echo random-number "$RANDOM_NUMBER"
shell: bash
env:
RANDOM_NUMBER: ${{ steps.foo.outputs.random-number }}
GitHub์ ๋ํ ๋ณตํฉ ์์ ์์
GitHub์์ ๋ณตํฉ ์์ ์ ๋ง์ ์๋ฅผ ์ฐพ์ ์ ์์ต๋๋ค.