やってみる

アウトプットすべく己を導くためのブログ。その試行錯誤すらたれ流す。

GitHubActionを試してみる4

 cscコマンドでビルドし、chmodで権限を与えて、実行する。

成果物

前回まで

プロジェクト

  • ./src/Program.cs
  • ./.github/workflows/csc.yml

src/Program.cs

using System;

class Program
{
    static void Main()
    {
        Console.WriteLine("Hello world");
    }
}

.github/workflows/csc.yml

name: csc

on: [push]

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v1
    - name: Setup .NET Core
      uses: actions/setup-dotnet@v1
      with:
        dotnet-version: 3.0.100
    - name: Build with csc
      working-directory: src
      run: |
        csc -nologo -recurse:*.cs -nullable:enable -langversion:latest
        chmod 755 *.exe
        ./*.exe

失敗ログ

失敗ログ

 GitHubサイトの当該リモートリポジトリを閲覧する。Actionをクリックするとcscがあるのでクリックする。実行ログが閲覧できる。

### ERRORED 03:52:03Z

- Your workflow file was invalid: The pipeline is not valid. .github/workflows/csc.yml: (Line: 18, Col: 14, Idx: 287) - (Line: 18, Col: 34, Idx: 307): While scanning a plain scalar, find unexpected ':'.

 シェルコマンドにあるパイプラインは無効らしい。え、使えないの?

before

      run: { csc -nologo -recurse:*.cs -nullable:enable -langversion:latest; chmod 755 *.exe; ./*.exe; }

after

      run: csc -nologo -recurse:*.cs -nullable:enable -langversion:latest
      run: chmod 755 *.exe
      run: ./*.exe

 ググってみた。

name: My Workflow

on: [push]

jobs:
  runMultipleCommands:
    runs-on: ubuntu-latest
    steps:
     - uses: actions/checkout@v1
     - run: |
        echo "A initial message"
        pip install -r requirements.txt
        echo "Another message or command"
        python myscript.py
        bash some-shell-script-file.sh -xe
     - run: echo "One last message"

before

      run: csc -nologo -recurse:*.cs -nullable:enable -langversion:latest
      run: chmod 755 *.exe
      run: ./*.exe

after

    - run: |
        csc -nologo -recurse:*.cs -nullable:enable -langversion:latest
        chmod 755 *.exe
        ./*.exe

 pushするも以下エラー。

every step must define a uses or run key

 余計な-を消すと成功した。

before

    - run: |
        csc -nologo -recurse:*.cs -nullable:enable -langversion:latest
        chmod 755 *.exe
        ./*.exe

after

      run: |
        csc -nologo -recurse:*.cs -nullable:enable -langversion:latest
        chmod 755 *.exe
        ./*.exe

 ちなみに|は公式にも説明があった。

ステータスバッジ

 no statusという灰色のバッジが表示された。数分後にページ更新するとpassingという緑色のバッジになった。

![](https://github.com/ytyaru/CSharp.GitHubAction.csc.run.20191117124118/workflows/csc/badge.svg)

所感

 最低限は把握できたと思う。

対象環境

$ uname -a
Linux raspberrypi 4.19.42-v7+ #1218 SMP Tue May 14 00:48:17 BST 2019 armv7l GNU/Linux