5
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

GitHub Actions の YAML で RUN にコメントを入れる

Last updated at Posted at 2021-07-17

Workflow の RUN 内でコメント行を入れたい

GitHub Actions の Workflow で、YAML の run ディレクティブ(指示子)でコメントを入れたい(# コメント 行を挿入したい)がエラーが出る。

"github actions yaml comment" でググってrun 内でコメントを扱う方法がなかなかヒットしなかったので、自分のググラビリティとして。

TL; DR (今北産業)

  • シェルの :# オペランドを使う
"true"を返すだけのコマンド(コロン)を実行してコメントを付ける
- run: echo "foo bar"
+ run: |
+   : # Sample
+   echo "foo bar"
具体例
# Sample workflow
on:
  push:
    branches: ['main']
  schedule:
    # Run at AM 03:00 on every Monday
    - cron:  '0 3 * * MON'

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository
        uses: actions/checkout@v2

      # Check the : and # at the run
      - name: Get date and version
        id: info
        run: |
          : # Get current date (YYMMDD)
          echo "::set-output name=date::$(date +'%Y%m%d')"
          : # Get latest git tag as a version
          ver_long="$(git describe --tags)"
          ver_short=$(git describe --tags | grep -o -E "([0-9]+\.){1}[0-9]+(\.[0-9]+)?" | head -n1)
          echo "::set-output name=ver_long::${ver_long}"
          echo "::set-output name=ver_short::${ver_short}"

      - name: Print version
        run: |
          echo "Ver(short): ${{ steps.info.outputs.ver_short }}"
          echo "Ver(long) : ${{ steps.info.outputs.ver_long }}"
          echo "Build date: ${{ steps.info.outputs.date }}"

参考文献

関連文献

5
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?