LoginSignup
2
1

More than 3 years have passed since last update.

GitHub Actionsでの機密情報の参照

Posted at

はじめに

GitHub Actions 皆様お使いでしょうか。
正式リリースされて一年ちょっと経っておりますので、大分利用されている方も増えてきている印象があります。
(無料枠ありますし。)
弊社でも GitHub Actions を活用しておりますが、各種キー情報など、機密情報をどのように扱うのかまとめてみました。
手順としては

1. GitHubのproject > setting > secrets
2. 1で登録したsecretキーを、GitHubActions上から参照

といった流れになります。

GitHub Actionsへの登録

GitHub上の、下記ページで設定を行います。
https://github.com/${account_name}/${project_name}/settings/secrets/actions
account_name , project_name は環境によって異なります。

ここでは、 SECRET_SAMPLE という名前で作成します。
スクリーンショット 2021-04-13 14.08.45.png

GitHub Actionsからの利用

name: CI
on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]
jobs:
  plan:
    name: test-workflow
    runs-on: ubuntu-latest
    steps:
      - name: checkout
        uses: actions/checkout@v2

      - name: Configure AWS credentials
        uses: aws-actions/configure-aws-credentials@v1
        with:
          aws-access-key-id: ${{ secrets.SECRET_SAMPLE }}

      - name: command run 
        run: | 
          aws sts get-caller-identity

参考情報

2
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
2
1