CI/CD内でshellを実行してjsonファイルを作成したいのですが、上手くいかずに困っています。
現在、github Actionsを使っていまして、その中でデプロイに必要なデータをもつJSONファイルを作成したいと思っています。
(Actions Secretsに登録されている値をシェルの中で使用し、jsonファイルを作成します。)
しかし、ファイルが作成されずにdeployができません。
ターミナル上で以下のコマンドを実行すると問題なくファイルが作成されます。
sudo
1 2sudo bash deployment/setup_claspjson.sh
何か問題があるのでしょうか?
やりたいことはこちらの記事と同じです。
全く同じやり方でも上手くいかなかったのでjsonファイルの生成方法を少し変えています。
githubcAtions ymlファイル
dev-deploy.yml # This is a basic workflow to help you get started with Actions name: Dev-CI env: ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }} ID_TOKEN: ${{ secrets.ID_TOKEN }} REFRESH_TOKEN: ${{ secrets.REFRESH_TOKEN }} CLIENT_ID: ${{ secrets.CLIENT_ID }} CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }} SCRIPT_ID: ${{ secrets.SCRIPT_ID_DEV}} # Controls when the action will run. Triggers the workflow on push or pull request # events but only for the main branch on: push: branches: [ dev ] # A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: merged-action: runs-on: ubuntu-latest steps: - name: pull uses: actions/checkout@v2 with: ref: ${{github.event.pull_request.head.ref}} - name: Node Install run: | sudo apt install nodejs sudo apt install npm - name: Node Version run: | echo "Node $(node -v)" echo "Npm $(npm -v)" - name: clasp install run: sudo npm i @google/clasp -g - name: Generate ~/.clasprc.json run: | bash deployment/setup.sh - name: Generate ~/.clasp.json run: | bash deployment/setup_claspjson.sh - name: push run: | sudo clasp push --force
shellファイル
setup.sh #!/bin/sh cat > /.clasprc.json << LOGIN { "token": { "access_token": "$ACCESS_TOKEN", "refresh_token": "$REFRESH_TOKEN", "scope": "https://www.googleapis.com/auth/cloud-platform https://www.googleapis.com/auth/drive.file https://www.googleapis.com/auth/service.management https://www.googleapis.com/auth/script.deployments https://www.googleapis.com/auth/logging.read https://www.googleapis.com/auth/script.webapp.deploy https://www.googleapis.com/auth/userinfo.profile openid https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/script.projects https://www.googleapis.com/auth/drive.metadata.readonly", "token_type": "Bearer", "id_token": "$ID_TOKEN", "expiry_date": 1595752666211 }, "oauth2ClientSettings": { "clientId": "$CLIENT_ID", "clientSecret": "$CLIENT_SECRET", "redirectUri": "http://localhost" }, "isLocalCreds": false } LOGIN
setup_claspjson.sh #!/bin/sh cat > ~/.clasp.json << CLASPJSON { "scriptId": "$SCRIPT_ID" } CLASPJSON
あなたの回答
tips
プレビュー