LoginSignup
6
4

More than 3 years have passed since last update.

GitHub Actionsでブランチ名やコミットSHA等のプロパティーを取得、表示する方法

Posted at

Example

手動で実行していくつかのプロパティーをechoで表示する例

${{ プロパティー名 }}と書くとその部分を置き換えてくれる

show-properties.yml
name: Show Properties

on: 
  workflow_dispatch:
    inputs:
      comment:
        description: "コメント"
        required: false
        default: "手動ビルド"

jobs:
  show-properties:
    runs-on: ubuntu-latest
    steps:
      - name: Show github properties
        run: | 
          echo ${{ github.workflow }}
          echo ${{ github.ref }}
          echo ${{ github.sha }}
      - name: Show secret properties
        run: | 
          echo ${{ secrets.SAMPLE }}
      - name: Show inputs properties
        run: |
          echo ${{ github.event.inputs.comment }}

secrets

アクセストークンやメールアドレス等隠したい情報は以下でsecretsとして登録する。
スクリーンショット_2020-10-24_23_56_40.png

今回はSAMPLEという名前で登録してある

結果

スクリーンショット 2020-10-24 23.53.47.png

スクリーンショット 2020-10-24 23.58.46.png

このように情報がとってこれておりechoによって出力できている。
ただし、secretsに関してはログにも表示されないようになっている。

プロパティーの詳細や、他のプロパティー、使える関数について知りたい場合には下記参考のリンクを参照。

参考

GitHub Actions のコンテキストおよび式の構文

ここに他のプロパティーや使える関数も記載されている

6
4
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
6
4