Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GitHub Actions の環境変数をビルドで利用できるようにする #1669

Merged
4 commits merged into from May 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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