LoginSignup
0
0

More than 1 year has passed since last update.

GitHub ActionsでのNode.js利用のアップデートメモ

Posted at

エラーではないけどアラートが出ていた

Node.js 12 actions are deprecated. For more information see: https://github.blog/changelog/2022-09-22-github-actions-all-actions-will-begin-running-on-node16-instead-of-node12/. Please update the following actions to use Node.js 16: actions/checkout, actions/setup-node, actions/checkout

スクリーンショット 2022-11-11 12.46.21.png

書き方古いから新しくしてね的な内容っぽいです。

今まで

name: xxを実行

on:
  push:
    branches: [ main ]

jobs:
  build:

    runs-on: ubuntu-latest
    timeout-minutes: 30

    strategy:
      matrix:
        node-version: [18.x]

    steps:
    - uses: actions/checkout@v2

    - name: Use Node.js 18.x
      uses: actions/setup-node@v1
      with:
        node-version: '18.x'

    - name: yarn install command
      run: yarn install

    - name: start action...
      run: > 
        XX_TOKEN=${{secrets.XX_TOKEN}}
        YY_TOKEN=${{secrets.YY_TOKEN}}
        node app.js

アップデート

公式ドキュメントに書いてあるサンプルをもとに書き直してみました。

https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs

  • actions/checkout@v2の箇所をactions/checkout@v3
  • actions/setup-node@v1の箇所をactions/setup-node@v3

が主な変更っぽいです。
↓にはそれ以外にも調べてでてきたキャッシュ処理も入れてますがなくても動きます。

name: 実行

on:
  push:
  	branches: [ main ]

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v3
      - name: Use Node.js
        uses: actions/setup-node@v3
        with:
          node-version: '18.x'

      # キャッシュ
      - name: Cache dependencies
        uses: actions/cache@v2
        with:
          path: ~/.npm
          key: npm-${{ hashFiles('package-lock.json') }}
          restore-keys: npm-

      # インストール
      - name: yarn install command
        run: yarn install

      # 実際のコマンド
      - name: start action...
        run: > 
          XX_TOKEN=${{secrets.XX_TOKEN}}
          YY_TOKEN=${{secrets.YY_TOKEN}}
          node app.js
0
0
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
0
0