Skip to content

Instantly share code, notes, and snippets.

@syossan27
Created December 17, 2021 14:37
Show Gist options
  • Save syossan27/9b87e603d3ac6c0c82255fc2e3e42319 to your computer and use it in GitHub Desktop.
Save syossan27/9b87e603d3ac6c0c82255fc2e3e42319 to your computer and use it in GitHub Desktop.
# 未使用に切り替えボタンが押下されたら指定されたアプリ/開発環境を未使用に変更
name: Change ENV by button
# repository_dispatchにより、外部から発火
# 参考URL: https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows#repository_dispatch
on:
repository_dispatch:
types: [change_env_1_by_button, change_env_2_by_button, change_env_3_by_button]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: リポジトリのチェックアウト
uses: actions/checkout@v1
- name: Google Cloud SDKのセットアップ
uses: google-github-actions/[email protected]
with:
project_id: ${{ secrets.PROJECT_ID }}
service_account_key: ${{ secrets.GCP_SA_KEY }}
export_default_credentials: true
- name: 開発環境1を未使用に変更
if: github.event.action == 'change_env_1_by_button'
run: |
touch 1.txt
echo ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY} > 1.txt
gsutil -h "Cache-Control: no-store" -m cp -r ./1.txt gs://example-bucket/app-1/
gsutil -h "Cache-Control: no-store" -m cp -r gs://example-bucket/red.png gs://example-bucket/app-1/1.png
- name: 開発環境2を未使用に変更
if: github.event.action == 'change_env_2_by_button'
run: |
touch 2.txt
echo ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY} > 2.txt
gsutil -h "Cache-Control: no-store" -m cp -r ./2.txt gs://example-bucket/app-1/
gsutil -h "Cache-Control: no-store" -m cp -r gs://example-bucket/red.png gs://example-bucket/app-1/2.png
- name: 開発環境3を未使用に変更
if: github.event.action == 'change_env_3_by_button'
run: |
touch 3.txt
echo ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY} > 3.txt
gsutil -h "Cache-Control: no-store" -m cp -r ./3.txt gs://example-bucket/app-1/
gsutil -h "Cache-Control: no-store" -m cp -r gs://example-bucket/red.png gs://example-bucket/app-1/3.png
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment