Skip to content

Commit 2e9cdf0

Browse files
Refactor Github Action per b/485167538
1 parent 81f89d5 commit 2e9cdf0

File tree

12 files changed

+70
-30
lines changed

12 files changed

+70
-30
lines changed

.github/actions/bash/action.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,6 @@ runs:
2424

2525
- name: Run
2626
shell: bash
27-
run: ${{ inputs.command }}
27+
run: ${INPUTS_COMMAND}
28+
env:
29+
INPUTS_COMMAND: ${{ inputs.command }}

.github/actions/bazel-docker/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ runs:
4747

4848
- name: Hook up repository Cache
4949
shell: bash
50-
run: echo "BAZEL_FLAGS=$BAZEL_FLAGS --repository_cache='/workspace/${{ env.REPOSITORY_CACHE_PATH }}'" >> $GITHUB_ENV
50+
run: echo "BAZEL_FLAGS=$BAZEL_FLAGS --repository_cache='/workspace/${REPOSITORY_CACHE_PATH}'" >> $GITHUB_ENV
5151

5252
- name: Validate inputs
5353
if: ${{ (inputs.bash && inputs.bazel) || (!inputs.bash && !inputs.bazel) }}

.github/actions/bazel/action.yml

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ runs:
7878

7979
- name: Hook up repository Cache
8080
shell: bash
81-
run: echo "BAZEL_FLAGS=$BAZEL_FLAGS --repository_cache=$(pwd)/${{ env.REPOSITORY_CACHE_PATH }}" >> $GITHUB_ENV
81+
run: echo "BAZEL_FLAGS=$BAZEL_FLAGS --repository_cache=$(pwd)/${REPOSITORY_CACHE_PATH}" >> $GITHUB_ENV
8282

8383
- name: Validate inputs
8484
if: ${{ (inputs.bash && inputs.bazel) || (!inputs.bash && !inputs.bazel) }}
@@ -87,7 +87,9 @@ runs:
8787

8888
- name: Pin Bazel version
8989
shell: bash
90-
run: echo "USE_BAZEL_VERSION=${{ inputs.version }}" >> $GITHUB_ENV
90+
run: echo "USE_BAZEL_VERSION=${INPUTS_VERSION}" >> $GITHUB_ENV
91+
env:
92+
INPUTS_VERSION: ${{ inputs.version }}
9193

9294
- name: Output Bazel version
9395
shell: bash
@@ -106,7 +108,7 @@ runs:
106108
shell: bash
107109
run: |
108110
mkdir -p mac_bazel_workaround
109-
bazelisk ${{ steps.bazel.outputs.bazel-startup-flags }} build @bazel_tools//tools/osx:xcode_locator.m $BAZEL_FLAGS
111+
bazelisk ${STEPS_BAZEL_OUTPUTS_BAZEL_STARTUP_FLAGS} build @bazel_tools//tools/osx:xcode_locator.m $BAZEL_FLAGS
110112
XCODE_LOCATOR_FLAGS="--sdk macosx clang -mmacosx-version-min=10.9 -fobjc-arc -framework CoreServices -framework Foundation"
111113
SINGLE_ARCH_COMPILE_FLAGS="--sdk macosx clang -mmacosx-version-min=10.9 -std=c++11 -lc++ -O3"
112114
COMPILE_FLAGS="$SINGLE_ARCH_COMPILE_FLAGS -arch arm64 -arch x86_64 -Wl,-no_adhoc_codesign -Wl,-no_uuid -O3"
@@ -115,18 +117,25 @@ runs:
115117
time env -i DEVELOPER_DIR=$DEVELOPER_DIR xcrun $COMPILE_FLAGS -o mac_bazel_workaround/libtool_check_unique $(bazel info output_base)/external/bazel_tools/tools/objc/libtool_check_unique.cc
116118
time env -i DEVELOPER_DIR=$DEVELOPER_DIR xcrun $SINGLE_ARCH_COMPILE_FLAGS -o mac_bazel_workaround/wrapped_clang $(bazel info output_base)/external/bazel_tools/tools/osx/crosstool/wrapped_clang.cc
117119
time env -i DEVELOPER_DIR=$DEVELOPER_DIR xcrun $COMPILE_FLAGS -o mac_bazel_workaround/wrapped_clang $(bazel info output_base)/external/bazel_tools/tools/osx/crosstool/wrapped_clang.cc
120+
env:
121+
STEPS_BAZEL_OUTPUTS_BAZEL_STARTUP_FLAGS: ${{ steps.bazel.outputs.bazel-startup-flags }}
118122

119123
- name: Run Bash
120124
if: ${{ inputs.bash }}
121-
run: ${{ inputs.bash }}
125+
run: ${INPUTS_BASH}
122126
shell: bash
127+
env:
128+
INPUTS_BASH: ${{ inputs.bash }}
123129

124130
- name: Run Bazel
125131
if: ${{ !inputs.bash }}
126132
run: >-
127-
bazelisk ${{ steps.bazel.outputs.bazel-startup-flags }}
128-
${{ inputs.bazel }} $BAZEL_FLAGS
133+
bazelisk ${STEPS_BAZEL_OUTPUTS_BAZEL_STARTUP_FLAGS}
134+
${INPUTS_BAZEL} $BAZEL_FLAGS
129135
shell: bash
136+
env:
137+
STEPS_BAZEL_OUTPUTS_BAZEL_STARTUP_FLAGS: ${{ steps.bazel.outputs.bazel-startup-flags }}
138+
INPUTS_BAZEL: ${{ inputs.bazel }}
130139

131140
- name: Save Bazel repository cache
132141
# Only allow repository cache updates during post-submits.

.github/actions/cross-compile-protoc/action.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ runs:
2828
2929
- name: Set protoc environment variable
3030
shell: bash
31-
run: echo "PROTOC=protoc-${{ inputs.architecture }}" >> $GITHUB_ENV
31+
run: echo "PROTOC=protoc-${INPUTS_ARCHITECTURE}" >> $GITHUB_ENV
32+
env:
33+
INPUTS_ARCHITECTURE: ${{ inputs.architecture }}
3234

3335
- name: Extract binary
3436
id: output

.github/actions/docker/action.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ runs:
4040
- name: Generate docker flags
4141
if: inputs.platform
4242
shell: bash
43-
run: echo "DOCKER_RUN_FLAGS=--platform ${{inputs.platform}}" >> $GITHUB_ENV
43+
run: echo "DOCKER_RUN_FLAGS=--platform ${INPUTS_PLATFORM}" >> $GITHUB_ENV
44+
env:
45+
INPUTS_PLATFORM: ${{inputs.platform}}
4446

4547
- name: Run Docker
4648
uses: ./.github/actions/internal/docker-run

.github/actions/internal/bazel-setup/action.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,11 @@ runs:
5353
shell: bash
5454
run: >-
5555
echo "BAZEL_FLAGS=$BAZEL_FLAGS
56-
--google_credentials=${{ inputs.credentials-file }}
57-
--remote_cache=https://storage.googleapis.com/protobuf-bazel-cache/protobuf/gha/${{ inputs.bazel-cache }}" >> $GITHUB_ENV
56+
--google_credentials=${INPUTS_CREDENTIALS_FILE}
57+
--remote_cache=https://storage.googleapis.com/protobuf-bazel-cache/protobuf/gha/${INPUTS_BAZEL_CACHE}" >> $GITHUB_ENV
58+
env:
59+
INPUTS_CREDENTIALS_FILE: ${{ inputs.credentials-file }}
60+
INPUTS_BAZEL_CACHE: ${{ inputs.bazel-cache }}
5861

5962
- name: Configure Bazel cache writing
6063
# External runs should never write to our caches.

.github/actions/internal/ccache-setup-windows/action.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,16 @@ runs:
1919
- name: Setup ccache path
2020
shell: bash
2121
run: |
22-
echo "CCACHE_EXE_PATH=$LOCALAPPDATA\ccache-${{ inputs.ccache-version }}-windows-x86_64" >> $GITHUB_ENV
23-
echo "$LOCALAPPDATA\ccache-${{ inputs.ccache-version }}-windows-x86_64" >> $GITHUB_PATH
22+
echo "CCACHE_EXE_PATH=$LOCALAPPDATA\ccache-${INPUTS_CCACHE_VERSION}-windows-x86_64" >> $GITHUB_ENV
23+
echo "$LOCALAPPDATA\ccache-${INPUTS_CCACHE_VERSION}-windows-x86_64" >> $GITHUB_PATH
24+
env:
25+
INPUTS_CCACHE_VERSION: ${{ inputs.ccache-version }}
2426

2527
- name: Add ccache to Powershell path
2628
shell: pwsh
27-
run: echo "%LOCALAPPDATA%\ccache-${{ inputs.ccache-version }}-windows-x86_64" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
29+
run: echo "%LOCALAPPDATA%\ccache-$env:INPUTS_CCACHE_VERSION-windows-x86_64" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
30+
env:
31+
INPUTS_CCACHE_VERSION: ${{ inputs.ccache-version }}
2832

2933
- name: Setup caching of ccache download
3034
if: ${{ github.event_name != 'pull_request' && github.event_name != 'pull_request_target' }}
@@ -47,10 +51,12 @@ runs:
4751
if: ${{ steps.ccache-cache.outputs.cache-hit != 'true' && steps.ccache-restore.outputs.cache-hit != 'true'}}
4852
run: |
4953
cd $LOCALAPPDATA
50-
curl -kLSs "https://github.com/ccache/ccache/releases/download/v${{ inputs.ccache-version }}/ccache-${{ inputs.ccache-version }}-windows-x86_64.zip" -o ccache.zip
54+
curl -kLSs "https://github.com/ccache/ccache/releases/download/v${INPUTS_CCACHE_VERSION}/ccache-${INPUTS_CCACHE_VERSION}-windows-x86_64.zip" -o ccache.zip
5155
unzip ccache.zip
5256
rm ccache.zip
5357
ccache --version
58+
env:
59+
INPUTS_CCACHE_VERSION: ${{ inputs.ccache-version }}
5460

5561
- name: Configure ccache environment variables
5662
shell: pwsh

.github/actions/internal/docker-run/action.yml

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,22 +41,32 @@ runs:
4141
shell: bash
4242
if: ${{ inputs.docker-cache && steps.check-docker-cache.outputs.cache-hit != 'true' }}
4343
run: >
44-
time docker pull -q ${{ inputs.image }} &&
45-
mkdir -p ci/docker/$(dirname ${{ inputs.image }}) &&
46-
time docker image save ${{ inputs.image }} --output ./ci/docker/${{ inputs.image }}.tar
44+
time docker pull -q ${INPUTS_IMAGE} &&
45+
mkdir -p ci/docker/$(dirname ${INPUTS_IMAGE}) &&
46+
time docker image save ${INPUTS_IMAGE} --output ./ci/docker/${INPUTS_IMAGE}.tar
47+
env:
48+
INPUTS_IMAGE: ${{ inputs.image }}
4749

4850
- name: Use the cached image on cache hit
4951
shell: bash
5052
if: ${{ inputs.docker-cache && steps.check-docker-cache.outputs.cache-hit == 'true' }}
51-
run: time docker image load --input ./ci/docker/${{ inputs.image }}.tar
53+
run: time docker image load --input ./ci/docker/${INPUTS_IMAGE}.tar
54+
env:
55+
INPUTS_IMAGE: ${{ inputs.image }}
5256

5357
- name: Pull fresh docker image
5458
shell: bash
5559
if: ${{ !inputs.docker-cache }}
56-
run: time docker pull -q ${{ inputs.image }}
60+
run: time docker pull -q ${INPUTS_IMAGE}
61+
env:
62+
INPUTS_IMAGE: ${{ inputs.image }}
5763

5864
- name: Run docker
5965
shell: bash
6066
run: >
61-
time docker run ${{ inputs.run-flags}} -v${{ github.workspace }}:/workspace
62-
${{ inputs.image }} ${{ inputs.command }}
67+
time docker run ${INPUTS_RUN_FLAGS} -v${{ github.workspace }}:/workspace
68+
${INPUTS_IMAGE} ${INPUTS_COMMAND}
69+
env:
70+
INPUTS_RUN_FLAGS: ${{ inputs.run-flags}}
71+
INPUTS_IMAGE: ${{ inputs.image }}
72+
INPUTS_COMMAND: ${{ inputs.command }}

.github/actions/internal/gcloud-auth/action.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ runs:
2727

2828
- name: Store credentials path
2929
shell: bash
30-
run: echo "CREDENTIALS_FILE=${{ steps.auth.outputs.credentials_file_path }}" >> $GITHUB_ENV
30+
run: echo "CREDENTIALS_FILE=${STEPS_AUTH_OUTPUTS_CREDENTIALS_FILE_PATH}" >> $GITHUB_ENV
31+
env:
32+
STEPS_AUTH_OUTPUTS_CREDENTIALS_FILE_PATH: ${{ steps.auth.outputs.credentials_file_path }}
3133

3234
- name: Fix credentials path (Windows)
3335
if: ${{ runner.os == 'Windows' }}
@@ -39,4 +41,4 @@ runs:
3941
- name: Output credentials file
4042
id: output
4143
shell: bash
42-
run: echo "credentials-file=${{ env.CREDENTIALS_FILE }}" >> $GITHUB_OUTPUT
44+
run: echo "credentials-file=${CREDENTIALS_FILE}" >> $GITHUB_OUTPUT

.github/actions/internal/repository-cache-restore/action.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@ runs:
2424
run: |
2525
REPOSITORY_CACHE_BASE=repository-cache-${{ github.base_ref || github.ref_name }}-${{ runner.os }}
2626
echo "REPOSITORY_CACHE_BASE=$REPOSITORY_CACHE_BASE" >> $GITHUB_ENV
27-
echo "REPOSITORY_CACHE_NAME=$REPOSITORY_CACHE_BASE-${{ inputs.bazel-cache}}-${{ github.sha }}" >> $GITHUB_ENV
27+
echo "REPOSITORY_CACHE_NAME=$REPOSITORY_CACHE_BASE-${INPUTS_BAZEL_CACHE}-${{ github.sha }}" >> $GITHUB_ENV
2828
echo "REPOSITORY_CACHE_PATH=.repository-cache" >> $GITHUB_ENV
29+
env:
30+
INPUTS_BAZEL_CACHE: ${{ inputs.bazel-cache}}
2931

3032
- name: Restore Bazel repository cache
3133
id: restore-cache

0 commit comments

Comments
 (0)