記事が公開された瞬間にツイートする
ようやくつけました。めっちゃめんどくさかった 最終的なymlはこんな感じ # This is a basic workflow to help you get started with Actions name: CI # Controls when the action will run. Triggers the workflow on push or pull request # events but only for the master branch on: push: branches: [ master ] repository_dispatch: types: [trigger] # A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: # This workflow contains a single job called "build" build: # The type of runner that the job will run on runs-on: ubuntu-latest # Steps represent a sequence of tasks that will be executed as part of the job steps: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - name: Checkout 🛎️ uses: actions/checkout@v2 - name: setup node uses: actions/setup-node@v1 with: node-version: '10.x' - name: Cache dependencies uses: actions/cache@v1 with: path: ~/.npm key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} restore-keys: | ${{ runner.os }}-node- - name: install run: npm install . - name: generate run: npm run generate - name: Commit & Push changes uses: actions-js/push@master with: github_token: ${{ secrets.GITHUB_TOKEN }} branch: 'master' - name: Deploy via FTP uses: SamKirkland/FTP-Deploy-Action@3.0.0 with: ftp-server: ${{ secrets.FTP_HOST }} ftp-username: ${{ secrets.FTP_USERNAME }} ftp-password: ${{ secrets.FTP_PASSWORD }} git-ftp-args: --remote-root ${{ secrets.FTP_REMOTE_ROOT }} local-dir: dist/ - name: get title if: ${{ github.event.client_payload.type == 'new'}} id: myRequest uses: fjogeleit/http-request-action@master with: url: " github.event.client_payload.id }}" method: GET customHeaders: '{"X-API-KEY": "${{ secrets.X_API_KEY }}"}' - name: tweet if: ${{ github.event.client_payload.type == 'new'}} run: curl -X POST -H "Content-Type:application/json" -d '{"value1":"${{ fromJson(steps.myRequest.outputs.response).title }}","value2":" ${{ secrets.IFTTT_URL }} ちょうど空きができたので、tweetの部分はIFTTTでアプレットを作成(Twitterのアプリ登録めんどいしね) 投稿されたidを取得するのは簡単だったけど、それを利用してtitleを取得してくるのがだるかった。。。 忘備録: idを指定したstepはsteps.[step_id].outputsで取得可能 JSON.parseはfromJson()でいける 事前にcurlしてそれを利用したい場合、このactionが良かった sawa-zenさんありがとうございました!
