Skip to main content

์ฝ”๋“œ ์˜ˆ์ œ์— ์ฃผ์„ ์ถ”๊ฐ€ํ•˜๊ธฐ

๋” ๊ธด ์ฝ”๋“œ ์˜ˆ์‹œ์— ์ฃผ์„์„ ์ถ”๊ฐ€ํ•˜์—ฌ ์ž‘์—… ๋ฐฉ์‹ ๋ฐ ๋‹ค๋ฅธ ์šฉ๋„๋กœ ์‚ฌ์šฉ์ž ์ง€์ •ํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์„ค๋ช…ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

์ฝ”๋“œ ์ฃผ์„ ์ •๋ณด

์ฝ”๋“œ ์ฃผ์„์€ ์ฝ”๋“œ ์˜ˆ์‹œ๊ฐ€ ์ˆ˜ํ–‰ํ•˜๋Š” ์ž‘์—…๊ณผ ์ด์œ ๋ฅผ ์„ค๋ช…ํ•˜์—ฌ ๋” ๊ธด ์ฝ”๋“œ ์˜ˆ์‹œ๋ฅผ ์„ค๋ช…ํ•˜๋Š” ๋ฐ ๋„์›€์ด ๋ฉ๋‹ˆ๋‹ค. ์ฃผ์„์€ ๋‘ ๊ฐœ์˜ ์ฐฝ ๋ ˆ์ด์•„์›ƒ์˜ ์ฝ”๋“œ ์˜ˆ์‹œ ์˜†์— ๋ Œ๋”๋ง๋˜๋ฏ€๋กœ ์ฝ”๋“œ ์ž์ฒด์˜ ๊ฐ€๋…์„ฑ์„ ํ•ด์น˜์ง€ ์•Š์œผ๋ฉด์„œ ๋” ๊ธด ์ฃผ์„์„ ์ž‘์„ฑํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ฝ”๋“œ ์กฐ๊ฐ์ด ์•„๋‹Œ ์ „์ฒด ์ฝ”๋“œ ์˜ˆ์‹œ์—๋งŒ ์ฃผ์„์„ ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค. ์ฝ”๋“œ ์ฃผ์„์€ ๋ชจ๋“  ์ฝ”๋“œ ์˜ˆ์‹œ์— ํ•„์š”ํ•˜์ง€ ์•Š์œผ๋ฉฐ ๋ฐ˜๋“œ์‹œ ํ•„์š”ํ•œ ๊ฒฝ์šฐ์—๋งŒ ์‚ฌ์šฉํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

์ฝ”๋“œ ์ฃผ์„์€ ๋‹ค์–‘ํ•œ ๋Œ€์ƒ ๊ทธ๋ฃน์— ์œ ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ฝ”๋“œ ์ฃผ์„์€ ์ข…์ข… ์‹ ๊ทœ ์‚ฌ์šฉ์ž์—๊ฒŒ ์ฃผ์š” ๊ฐœ๋…์„ ์„ค๋ช…ํ•˜๊ฑฐ๋‚˜ ๊ฒฝํ—˜์ด ํ’๋ถ€ํ•œ ์‚ฌ์šฉ์ž์—๊ฒŒ ํŠน์ • ์„ ํƒ์ง€๋ฅผ ์„ค๋ช…ํ•˜๋Š” ๋ฐ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค.

์ƒˆ ์‚ฌ์šฉ์ž์—๊ฒŒ ์ฝ”๋“œ ์ฃผ์„์€ ์ฝ”๋“œ ์˜ˆ์‹œ์˜ ๊ฐœ๋žต์ ์ธ ๊ฐœ์š”๋ฅผ ๋„˜์–ด ๊ฐ ์ฝ”๋“œ ์ค„์ด ์ˆ˜ํ–‰ํ•˜๋Š” ์ž‘์—…์„ ์„ค๋ช…ํ•˜์—ฌ ์นœ๊ตฌ๋‚˜ ๋™๋ฃŒ๊ฐ€ ์ฝ”๋“œ๋ฅผ ์•ˆ๋‚ดํ•˜๋Š” ๊ฒƒ์ฒ˜๋Ÿผ ์ฝ”๋“œ๋ฅผ ์ดํ•ดํ•  ์ˆ˜ ์žˆ๋„๋ก ํ•˜๋Š” ๋ฐฉ๋ฒ•์ž…๋‹ˆ๋‹ค.

๊ฒฝํ—˜์ด ๋งŽ์€ ์‚ฌ์šฉ์ž์—๊ฒŒ ์ฝ”๋“œ ์ฃผ์„์€ ์ฝ”๋“œ ์˜ˆ์‹œ๋ฅผ ์ดํ•ดํ•˜๊ณ  ํŠน์ • ์š”๊ตฌ ์‚ฌํ•ญ์— ๋งž๊ฒŒ ์กฐ์ •ํ•˜๋Š” ๋ฐ ๋„์›€์ด ๋  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ฃผ์„์€ ์ฝ”๋“œ๊ฐ€ ํŠน์ • ๋ฐฉ์‹์œผ๋กœ ์ž‘์„ฑ๋œ ์ด์œ ๋ฅผ ์„ค๋ช…ํ•˜์—ฌ ๊ธฐ๋ณธ ์‚ฌํ•ญ์ด ๋ช…ํ™•ํ•ด์ง€๋„๋ก ํ•ฉ๋‹ˆ๋‹ค.

๋‹จ์ผ ๋ฌธ์„œ์—์„œ ์—ฌ๋Ÿฌ ์ฝ”๋“œ ์˜ˆ์‹œ์— ์ฃผ์„์„ ๋‹ฌ ์ˆ˜ ์žˆ์ง€๋งŒ, ๊ฐ ์ฃผ์„์€ ๋ฌธ์„œ์˜ ๋ณต์žก์„ฑ์„ ์ฆ๊ฐ€์‹œํ‚ค๊ณ  ํ™”๋ฉด ์ฝ๊ธฐ ํ”„๋กœ๊ทธ๋žจ์„ ์‚ฌ์šฉํ•˜๋Š” ์‚ฌ์šฉ์ž์— ๋Œ€ํ•œ ๋ฐ˜๋ณต์ ์ธ ํƒ์ƒ‰ ์ž‘์—…์„ ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค. ๋ฌธ์„œ์— ์—ฌ๋Ÿฌ ์ฝ”๋“œ ์˜ˆ์‹œ๊ฐ€ ์žˆ๋Š” ๊ฒฝ์šฐ, ๋‹จ์ผ ์˜ˆ์‹œ๋กœ ๊ฒฐํ•ฉํ•  ์ˆ˜ ์žˆ๋Š”์ง€ ์—ฌ๋ถ€๋ฅผ ๊ณ ๋ คํ•ฉ๋‹ˆ๋‹ค.

์ฝ”๋“œ ์ฃผ์„ ์‚ฌ์šฉ ๋ฐ ์ถ”๊ฐ€ํ•˜๊ธฐ

  1. ๋ฌธ์„œ์˜ layout: inline ํ”„๋ŸฐํŠธ ๋งคํ„ฐ ์†์„ฑ์„ ์ง€์ •ํ•˜์„ธ์š”.
  2. ์‚ผ์ค‘ ๋ฐฑํ‹ฑ์„ ์‚ฌ์šฉํ•˜์—ฌ ์ฝ”๋“œ ์˜ˆ์‹œ๋ฅผ ๋งŒ๋“œ์„ธ์š”.
  3. 3์ค‘ ๋ฐฑํ‹ฑ ๋’ค์— ๋‹ค์Œ annotate์„(๋ฅผ) ์ž‡๋Š” ์ฝ”๋“œ ์˜ˆ์‹œ์— ๋Œ€ํ•œ ์–ธ์–ด๋ฅผ ์ง€์ •ํ•˜์„ธ์š”. ์˜ˆ๋ฅผ ๋“ค์–ด ```yaml annotate ๋˜๋Š” ```ruby annotate์ž…๋‹ˆ๋‹ค.
  4. ์ฝ”๋“œ ์˜ˆ์‹œ ๋‚ด์—์„œ ์ฃผ์„ ํƒœ๊ทธ(#, //, <&#33--, %%)๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์ฃผ์„์„ ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค. ์ฝ”๋“œ ์ƒ˜ํ”Œ์ด ์ž‘์„ฑ๋œ ์–ธ์–ด์—๋Š” ์ฃผ์„ ํƒœ๊ทธ๋ฅผ ์‚ฌ์šฉํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด YAML์—๋Š” #์ด๊ณ  JavaScript์—๋Š” //์ž…๋‹ˆ๋‹ค.
    • ์ฃผ์„์ด ์ถ”๊ฐ€๋œ ์ฝ”๋“œ ์˜ˆ์‹œ๋Š” ๋ฐ˜๋“œ์‹œ ํ•œ ์ค„ ์ฃผ์„์œผ๋กœ ์‹œ์ž‘ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ์ฒซ ๋ฒˆ์งธ ์ฝ”๋“œ ์ค„์— ์ฃผ์„์„ ์ถ”๊ฐ€ํ•˜์ง€ ์•Š์œผ๋ ค๋ฉด ๋นˆ ์ฃผ์„์œผ๋กœ ์‹œ์ž‘ํ•˜๋ฉด ๋ฉ๋‹ˆ๋‹ค.
    • ์ฃผ์„์€ ์ฃผ์„ ํƒœ๊ทธ ์•„๋ž˜ ์ค„์˜ ์ฝ”๋“œ์—์„œ ๋‹ค์Œ ์ฃผ์„ ํƒœ๊ทธ ๋˜๋Š” ์ฝ”๋“œ ๋ธ”๋ก์˜ ๋์— ์ ์šฉํ•ฉ๋‹ˆ๋‹ค.

์ฃผ์„ ๊ทœ์น™

๋‹ค์Œ์˜ ๊ทœ์น™์€ ๋ชจ๋“  ์ฝ”๋“œ ์ฃผ์„์— ์ ์šฉ๋ฉ๋‹ˆ๋‹ค.

  • /*์ฒ˜๋Ÿผ ์—ฌ๋Ÿฌ ์ค„ ์Šคํƒ€์ผ์˜ ์ฃผ์„์€ ์ง€์›๋˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.
  • ์ฝ”๋“œ ์ฃผ์„์„ ์‹œ์ž‘ํ•˜๋Š” ๊ธฐํ˜ธ์™€ ์ฃผ์„ ์‚ฌ์ด์—๋Š” ๊ณต๋ฐฑ์ด ์žˆ์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.
    • ์˜ฌ๋ฐ”๋ฅธ ์‚ฌ์šฉ: # comment
    • ์ž˜๋ชป๋œ ์‚ฌ์šฉ: #comment
  • ๋นˆ ์ฃผ์„์„ ๋งŒ๋“ค๋ ค๋ฉด ๊ทธ ๋’ค์— ํ…์ŠคํŠธ๊ฐ€ ์—†๋Š” ์„ค๋ช… ํƒœ๊ทธ๋ฅผ ์‚ฝ์ž…ํ•˜์„ธ์š”. ๋นˆ ์ฃผ์„์€ ์ƒ˜ํ”Œ์˜ ์ผ๋ถ€ ์ค„์—์„œ ์ฃผ์„์ด ํ•„์š”ํ•˜์ง€ ์•Š์€ ๊ฒฝ์šฐ์— ์œ ์šฉํ•ฉ๋‹ˆ๋‹ค.
  • #!๋กœ ์‹œ์ž‘ํ•˜๋Š” ๋ฌธ์ž์—ด์€ ์ฝ”๋“œ ๋ธ”๋ก์—์„œ ๋ Œ๋”๋ง๋˜๋ฉฐ ์ฃผ์„์œผ๋กœ ์ฒ˜๋ฆฌ๋˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.
  • ์„ค๋ช… ํƒœ๊ทธ ๋’ค์˜ ๋ชจ๋“  ํ•ญ๋ชฉ์€ Markdown์œผ๋กœ ๊ตฌ๋ฌธ ๋ถ„์„๋  ๊ฒƒ์ž…๋‹ˆ๋‹ค. ๋งํฌ, ๋ฒ„์ „ ๊ด€๋ฆฌ ๋ฐ ๊ธฐํƒ€ ์Šคํƒ€์ผ์€ Markdown์— ์ž‘์„ฑ๋œ ๊ฒƒ์ฒ˜๋Ÿผ ๋ Œ๋”๋ง๋  ๊ฒƒ์ž…๋‹ˆ๋‹ค.
  • ์—ฌ๋Ÿฌ ์ˆœ์ฐจ ์„ค๋ช…์€ ๋‹จ์ผ ์ฃผ์„์„ ๋งŒ๋“ญ๋‹ˆ๋‹ค.
  • ์„ค๋ช… ํƒœ๊ทธ๋กœ ์‹œ์ž‘ํ•˜์ง€ ์•Š๊ณ  ๋น„์–ด ์žˆ๊ฑฐ๋‚˜ ๊ณต๋ฐฑ๋งŒ ํฌํ•จ๋œ ์ค„์€ ๋ฌด์‹œ๋  ๊ฒƒ์ž…๋‹ˆ๋‹ค.
  • ๋‹จ์ผ ์ค„์˜ ์„ค๋ช…์„ ์‚ฌ์šฉํ•˜์—ฌ ์ฝ”๋“œ ๊ตฌ์—ญ์„ ์‹œ์ž‘ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ์ฝ”๋“œ์˜ ์ฒซ ๋ฒˆ์งธ ์ค„(๋˜๋Š” ๊ตฌ์—ญ)์— ์ฃผ์„์ด ํ•„์š”ํ•˜์ง€ ์•Š์€ ๊ฒฝ์šฐ ํ…์ŠคํŠธ๊ฐ€ ์—†๋Š” ์„ค๋ช… ํƒœ๊ทธ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋นˆ ์ฃผ์„์„ ๋งŒ๋“ค ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
  • HTML ์Šคํƒ€์ผ์˜ ๊ฒฝ์šฐ ์ฃผ์„ ๋’ค์— ๋‹ซ๋Š” ํƒœ๊ทธ <!-- -->์„(๋ฅผ) ํฌํ•จํ•˜์—ฌ, ๊ตฌ๋ฌธ ๊ฐ•์กฐ ํ‘œ์‹œ๋ฅผ ์œ ์ง€ ๊ด€๋ฆฌํ•ฉ๋‹ˆ๋‹ค.

์ฝ”๋“œ ์ฃผ์„ ๋ชจ๋ฒ” ์‚ฌ๋ก€

์ฝ”๋“œ ๋ธ”๋ก ์•ž์˜ ์†Œ๊ฐœ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์ฝ”๋“œ ์˜ˆ์‹œ์˜ ์ „์ฒด ์šฉ๋„๋ฅผ ์†Œ๊ฐœํ•˜๊ณ  ์ฃผ์„์„ ์‚ฌ์šฉํ•˜์—ฌ ํŠน์ • ์ฝ”๋“œ ์ค„์ด ํ•˜๋Š” ์ž‘์—…๊ณผ ํ•ด๋‹น ์ฝ”๋“œ ์ค„์ด ์ˆ˜ํ–‰ํ•˜๋Š” ์ด์œ ๋ฅผ ์„ค๋ช…ํ•ฉ๋‹ˆ๋‹ค.

์ฝ”๋“œ ์ฃผ์„์„ ์ตœ๋Œ€ํ•œ ์งง๊ฒŒ ์œ ์ง€ํ•˜๋Š” ๋™์•ˆ ์ฝ”๋“œ ์ฃผ์„์˜ ๋ช…ํ™•์„ฑ ์šฐ์„  ์ˆœ์œ„๋ฅผ ์ง€์ •ํ•˜์„ธ์š”. ์ฝ”๋“œ ์ƒ˜ํ”Œ์„ ์ž์‹ ์˜ ์ž‘์—…์— ๋Œ€ํ•œ ๊ธฐ์ดˆ๋กœ ์‚ฌ์šฉํ•˜๋ฏ€๋กœ, ์ฃผ์„์€ ์ž‘์„ฑ๋˜๋Š” ์ƒ˜ํ”Œ๊ณผ ๋‹ค๋ฅธ ์šฉ๋„์— ๋งž๊ฒŒ ์ƒ˜ํ”Œ์„ ์กฐ์ •ํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์ดํ•ดํ•˜๋Š” ๋ฐ ๋„์›€์ด ๋ฉ๋‹ˆ๋‹ค.

์ฝ”๋“œ ์ฃผ์„์„ ์ž‘์„ฑํ•  ๋•Œ ๋Œ€์ƒ ๊ทธ๋ฃน์„ ๊ณ ๋ คํ•˜๊ณ  ์˜ˆ์‹œ๊ฐ€ ํŠน์ • ๋ฐฉ์‹์œผ๋กœ ์ž‘์„ฑ๋œ ์ด์œ ๋ฅผ ์‚ฌ๋žŒ๋“ค์ด ์•Œ ๊ฒƒ์ด๋ผ๊ณ  ๊ฐ€์ •ํ•˜์ง€ ๋งˆ์„ธ์š”.

์ฃผ์„์€ ์ฃผ์„์ด ๋‹ฌ๋ฆฐ ์ฝ”๋“œ์˜ ์˜ˆ์ƒ ๊ฒฐ๊ณผ๋ฅผ ํ‘œ์‹œํ•˜๋Š” ๋ฐ ์‚ฌ์šฉ๋  ์ˆ˜ ์žˆ์ง€๋งŒ, ์ „์ฒด ์ฝ”๋“œ ์˜ˆ์‹œ์˜ ๊ฒฐ๊ณผ๋Š” ๋Œ€์ƒ ๊ทธ๋ฃน์—๊ฒŒ ๊ฐ€์žฅ ์ ํ•ฉํ•œ ๋ฐฉ๋ฒ•์ด์–ด์•ผ ํ•˜๋ฉฐ, ์—ฌ๊ธฐ์—๋Š” ์ฝ”๋“œ ์˜ˆ์‹œ ์†Œ๊ฐœ ๋˜๋Š” ์˜ˆ์‹œ ๋‹ค์Œ์— ์„ค๋ช…ํ•˜๋Š” ๋ฐฉ๋ฒ•์ด ์žˆ์Šต๋‹ˆ๋‹ค.

์ฝ”๋“œ ์˜ˆ์‹œ๊ฐ€ ๋ณ€๊ฒฝ๋˜๋ฉด ๋ชจ๋“  ์ฃผ์„์ด ์—ฌ์ „ํžˆ ์œ ํšจํ•œ์ง€ ๊ฒ€์‚ฌํ•˜์„ธ์š”.

์ฃผ์„์ด ์ถ”๊ฐ€๋œ ์ฝ”๋“œ ์˜ˆ์‹œ์˜ ์˜ˆ์‹œ

๋‹ค์Œ ์˜ˆ์‹œ์—์„œ๋Š” ๋ Œ๋”๋ง๋œ ์ฝ”๋“œ ์ฃผ์„์˜ ๋ชจ์–‘๊ณผ ํ•ด๋‹น ์ฃผ์„์„ ๋งŒ๋“œ๋Š” ์›์‹œ ์ฝ”๋“œ๋ฅผ ๋ณด์—ฌ ์ค๋‹ˆ๋‹ค.

๋ Œ๋”๋ง ์˜ˆ์‹œ

๋‹ค์Œ ์ฝ”๋“œ ์˜ˆ์‹œ๋Š” ๋Œ์–ด์˜ค๊ธฐ ์š”์ฒญ์ด ์—ด๋ฆด ๋•Œ ํ™˜์˜ ๋ฉ”๋ชจ๋ฅผ ๊ฒŒ์‹œํ•˜๋Š” ์›Œํฌํ”Œ๋กœ์ž…๋‹ˆ๋‹ค.

YAML
name: Post welcome comment

The name of the workflow as it will appear in the "Actions" tab of the GitHub repository.

on:

The on keyword lets you define the events that trigger when the workflow is run.

  pull_request:
    types: [opened]

Add the pull_request event, so that the workflow runs automatically every time a pull request is created.

permissions:
  pull-requests: write

Modifies the default permissions granted to GITHUB_TOKEN.

jobs:
  build:
    name: Post welcome comment

Defines a job with the ID build that is stored within the jobs key.

    runs-on: ubuntu-latest

Configures the operating system the job runs on.

    steps:
      - run: gh pr comment $PR_URL --body "Welcome to the repository!"
        env:
          GH_TOKEN: $
          PR_URL: $

The run keyword tells the job to execute a command on the runner.

# The name of the workflow as it will appear in the "Actions" tab of the GitHub repository.
name: Post welcome comment
# The `on` keyword lets you define the events that trigger when the workflow is run.
on:
  # Add the `pull_request` event, so that the workflow runs automatically
  # every time a pull request is created.
  pull_request:
    types: [opened]
# Modifies the default permissions granted to `GITHUB_TOKEN`.
permissions:
  pull-requests: write
# Defines a job with the ID `build` that is stored within the `jobs` key.
jobs:
  build:
    name: Post welcome comment
    # Configures the operating system the job runs on.
    runs-on: ubuntu-latest
    # The `run` keyword tells the job to execute a command on the runner.
    steps:
      - run: gh pr comment $PR_URL --body "Welcome to the repository!"
        env:
          GH_TOKEN: $
          PR_URL: $

์›์‹œ ์ฝ”๋“œ ์˜ˆ์‹œ

The following code example shows a workflow that posts a welcome comment on a pull request when it is opened.

```yaml annotate
# The name of the workflow as it will appear in the "Actions" tab of the GitHub repository.
name: Post welcome comment
# The `on` keyword lets you define the events that trigger when the workflow is run.
on:
  # Add the `pull_request` event, so that the workflow runs automatically
  # every time a pull request is created.
  pull_request:
    types: [opened]
# Modifies the default permissions granted to `GITHUB_TOKEN`.
permissions:
  pull-requests: write
# Defines a job with the ID `build` that is stored within the `jobs` key.
jobs:
  build:
    name: Post welcome comment
    # Configures the operating system the job runs on.
    runs-on: ubuntu-latest
    # The `run` keyword tells the job to execute a command on the runner.
    steps:
      - run: gh pr comment $PR_URL --body "Welcome to the repository!"
        env:
          GH_TOKEN: $
          PR_URL: $
```