5
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

GitHub ActionsとCircleCIで実行するgitコマンド結果の違い

Last updated at Posted at 2020-03-03

はじめに

GitHub ActionsとCircleCIそれぞれで実行したgitコマンド結果に違いがあったので、そのメモです。

環境

  • actions/checkout@v2

git diff結果の違い

CircleCIでは、シェルスクリプト内で以下のgit diffコマンドを実行し、masterブランチとの差分ファイル名を洗い出して、後続で利用するよう、私の.circleci/config.ymlでは処理を組んでいました。

$ git diff --name-only origin/master...HEAD
ファイル名
ファイル名
ファイル名
...

しかし、GitHub Actionsでは、同じコマンドがfatal: ambiguous argumentのエラーとなります。

Run git diff --name-only origin/master...HEAD
fatal: ambiguous argument 'origin/master...HEAD': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
## [error]Process completed with exit code 128.```

git log結果を比較してみる

CircleCIも、GitHub Actionsも実行コンテナ内にSSHで入ることができます。

それぞれのやり方は以下を参照してください。

CircleCIの場合

git logで以下のように過去のcommit履歴が表示されます。

circleci@b89e46911691:~/project$ git log --oneline
f9a03f6 (HEAD -> actions_vs_circleci, origin/actions_vs_circleci, master) fix typo
6184539 use actions
e75c0c0 (origin/master, origin/HEAD) Merge pull request #1 from shonansurvivors/circleci-project-setup
88dee0f (略)
a33d927 (略)
e6d85f5 (略)
...

GitHub Actionsの場合

git logで表示されるのは、直近のcommit履歴だけです。

runner@fv-az16:~/work/laravel-ci/laravel-ci$ git log --oneline
f9a03f6 (grafted, HEAD -> actions_vs_circleci, origin/actions_vs_circleci) fix typo

終わりに

このような差異があるので、CircleCIでgitコマンドを使用して何らかの処理、条件分岐等を行なっている場合は、GitHub Actionsへの移行時には要注意です。

追記

actions/checkout@v1であれば、GitHub Actionsでも過去のcommit履歴が取得できます。

5
0
3

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
5
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?