Skip to content

Commit

Permalink
GitHub Actions の環境変数をビルドで利用できるようにする (#1669)
Browse files Browse the repository at this point in the history
- GHAのワークフロージョブに環境変数を設定するステップを追加
- AppVeyor及びAzure Pipelinesにおける`GITHUB_PR_HEAD_SHORT_COMMIT`の設定方法を変更
- githash.batのログ出力内容を調整
  • Loading branch information
Kohki Akikaze authored May 20, 2021
2 parents be97f80 + cf59e15 commit 6be2aec
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 13 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/build-sakura.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,35 @@ jobs:
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v1

- name: Setup environment variables
run: |
echo "CI_ACCOUNT_NAME=${{github.actor}}" >> $env:GITHUB_ENV
echo "CI_REPO_NAME=${{github.repository}}" >> $env:GITHUB_ENV
echo "CI_BUILD_VERSION=${{github.run_id}}" >> $env:GITHUB_ENV
echo "CI_BUILD_NUMBER=${{github.run_number}}" >> $env:GITHUB_ENV
echo("CI_BUILD_URL=" `
+ "${env:GITHUB_SERVER_URL}/${{github.repository}}/" `
+ "actions/runs/${{github.run_id}}") >> $env:GITHUB_ENV
echo("GITHUB_COMMIT_URL=" `
+ "${env:GITHUB_SERVER_URL}/${{github.repository}}/" `
+ "commit/${{github.sha}}") >> $env:GITHUB_ENV
if ('pull_request' -eq '${{github.event_name}}') {
echo("GITHUB_PR_NUMBER=" `
+ "${{github.event.pull_request.number}}") >> $env:GITHUB_ENV
echo("GITHUB_PR_HEAD_SHORT_COMMIT=" `
+ "${{github.event.pull_request.head.sha}}".SubString(0, 8)) >> $env:GITHUB_ENV
echo("GITHUB_PR_HEAD_COMMIT=" `
+ "${{github.event.pull_request.head.sha}}") >> $env:GITHUB_ENV
echo("GITHUB_PR_HEAD_URL=" `
+ "${env:GITHUB_SERVER_URL}/${{github.repository}}/" `
+ "pull/${{github.event.pull_request.number}}/" `
+ "commits/${{github.event.pull_request.head.sha}}") >> $env:GITHUB_ENV
}
shell: pwsh

- name: MSBuild
run: build-sln.bat ${{ matrix.platform }} ${{ matrix.config }}
shell: cmd
Expand Down
24 changes: 11 additions & 13 deletions sakura/githash.bat
Original file line number Diff line number Diff line change
Expand Up @@ -112,17 +112,13 @@ exit /b 0
)

if defined APPVEYOR_PULL_REQUEST_HEAD_COMMIT (
set GITHUB_PR_HEAD_SHORT_COMMIT=%APPVEYOR_PULL_REQUEST_HEAD_COMMIT:~0,8%
set GITHUB_PR_HEAD_COMMIT=%APPVEYOR_PULL_REQUEST_HEAD_COMMIT%
) else if defined SYSTEM_PULLREQUEST_SOURCECOMMITID (
set GITHUB_PR_HEAD_SHORT_COMMIT=%SYSTEM_PULLREQUEST_SOURCECOMMITID:~0,8%
set GITHUB_PR_HEAD_COMMIT=%SYSTEM_PULLREQUEST_SOURCECOMMITID%
)

if not "%GITHUB_PR_HEAD_COMMIT%" == "" (
set GITHUB_PR_HEAD_SHORT_COMMIT=%GITHUB_PR_HEAD_COMMIT:~0,8%
) else (
set GITHUB_PR_HEAD_SHORT_COMMIT=
)

if "%BUILD_REPOSITORY_PROVIDER%"=="GitHub" (
set GITHUB_ON=1
)
Expand Down Expand Up @@ -191,24 +187,26 @@ exit /b 0
del "%GITHASH_H_TMP%"
@echo %GITHASH_H% was not updated.
) else (
@echo GIT_TAG_NAME : %GIT_TAG_NAME%
@echo GIT_SHORT_COMMIT_HASH : %GIT_SHORT_COMMIT_HASH%
@echo GIT_COMMIT_HASH : %GIT_COMMIT_HASH%
@echo GIT_REMOTE_ORIGIN_URL : %GIT_REMOTE_ORIGIN_URL%
@echo GIT_TAG_NAME : %GIT_TAG_NAME%
@echo.
@echo CI_ACCOUNT_NAME : %CI_ACCOUNT_NAME%
@echo CI_REPO_NAME : %CI_REPO_NAME%
@echo CI_ACCOUNT_NAME : %CI_ACCOUNT_NAME%
@echo CI_BUILD_VERSION : %CI_BUILD_VERSION%
@echo CI_BUILD_NUMBER : %CI_BUILD_NUMBER%
@echo CI_BUILD_URL : %CI_BUILD_URL%
@echo CI_BUILD_VERSION : %CI_BUILD_VERSION%
@echo CI_BUILD_NUMBER : %CI_BUILD_NUMBER%
@echo CI_BUILD_URL : %CI_BUILD_URL%
@echo.
@echo GITHUB_COMMIT_URL : %GITHUB_COMMIT_URL%
@echo GITHUB_PR_HEAD_URL : %GITHUB_PR_HEAD_URL%
@echo GITHUB_PR_HEAD_COMMIT : %GITHUB_PR_HEAD_COMMIT%
@echo GITHUB_PR_NUMBER : %GITHUB_PR_NUMBER%
@echo GITHUB_PR_HEAD_SHORT_COMMIT : %GITHUB_PR_HEAD_SHORT_COMMIT%
@echo GITHUB_PR_HEAD_COMMIT : %GITHUB_PR_HEAD_COMMIT%
@echo GITHUB_PR_HEAD_URL : %GITHUB_PR_HEAD_URL%
@echo.
@echo APPVEYOR_URL : %APPVEYOR_URL%
@echo APPVEYOR_PROJECT_SLUG : %APPVEYOR_PROJECT_SLUG%
@echo.

if exist "%GITHASH_H%" del "%GITHASH_H%"
move /y "%GITHASH_H_TMP%" "%GITHASH_H%"
Expand Down

0 comments on commit 6be2aec

Please sign in to comment.