Skip to content

Commit de63b86

Browse files
Refactor Github Action per b/485167538
1 parent 7bf0359 commit de63b86

5 files changed

Lines changed: 45 additions & 22 deletions

File tree

.github/actions/build-debian-packages/action.yaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ runs:
1010
- name: Modify version format
1111
if: inputs.deploy-channel != ''
1212
run: |
13-
case "${{ inputs.deploy-channel }}" in
13+
case "${INPUTS_DEPLOY_CHANNEL}" in
1414
stable)
1515
# Stable version format : X.Y.Z
16-
SEMVER=$(echo ${{ github.ref_name }} | grep -oE '[0-9]+.[0-9]+.[0-9]+')
16+
SEMVER=$(echo ${GITHUB_REF_NAME} | grep -oE '[0-9]+.[0-9]+.[0-9]+')
1717
sed -i "1s/(\([0-9]\+.[0-9]\+.[0-9]\+\))/(${SEMVER})/g" \
1818
base/debian/changelog
1919
sed -i "1s/(\([0-9]\+.[0-9]\+.[0-9]\+\))/(${SEMVER})/g" \
@@ -24,7 +24,7 @@ runs:
2424
unstable|nightly)
2525
# Unstable/nightly version format : X.Y.Z~gitYYYYMMDDHHMM.<Github SHA 8 digit>
2626
SHORT_SHA=$(echo ${{ github.sha }} | cut -c1-8)
27-
SUFFIX="~git${{ inputs.yyyymmddhhmm }}.${SHORT_SHA}"
27+
SUFFIX="~git${INPUTS_YYYYMMDDHHMM}.${SHORT_SHA}"
2828
sed -i "1s/(\([0-9]\+.[0-9]\+.[0-9]\+\))/(\1${SUFFIX})/g" \
2929
base/debian/changelog
3030
sed -i "1s/(\([0-9]\+.[0-9]\+.[0-9]\+\))/(\1${SUFFIX})/g" \
@@ -37,6 +37,9 @@ runs:
3737
;;
3838
esac
3939
shell: bash
40+
env:
41+
INPUTS_DEPLOY_CHANNEL: ${{ inputs.deploy-channel }}
42+
INPUTS_YYYYMMDDHHMM: ${{ inputs.yyyymmddhhmm }}
4043
- name: Build CF debian packages
4144
run: |
4245
sudo docker build --file "tools/buildutils/cw/Containerfile" --tag "android-cuttlefish-build" .

.github/actions/deploy-debian-packages/action.yaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ runs:
1313
version: '>= 363.0.0'
1414
- name: Deploy deb packages into Artifact Registry
1515
run: |
16-
if [[ ${{ inputs.deploy-channel }} == "stable" ]]; then
16+
if [[ ${INPUTS_DEPLOY_CHANNEL} == "stable" ]]; then
1717
REPO=android-cuttlefish
1818
else
19-
REPO=android-cuttlefish-${{ inputs.deploy-channel }}
19+
REPO=android-cuttlefish-${INPUTS_DEPLOY_CHANNEL}
2020
fi
2121
22-
pushd ${{ inputs.path }}
22+
pushd ${INPUTS_PATH}
2323
for var in base user orchestration; do
2424
gcloud --project=android-cuttlefish-artifacts \
2525
artifacts apt upload \
@@ -34,3 +34,6 @@ runs:
3434
--source=$(find . -name cuttlefish-integration-gigabyte-arm64_*.deb)
3535
popd
3636
shell: bash
37+
env:
38+
INPUTS_DEPLOY_CHANNEL: ${{ inputs.deploy-channel }}
39+
INPUTS_PATH: ${{ inputs.path }}

.github/actions/deploy-docker-image/action.yaml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,22 @@ runs:
1111
steps:
1212
- name: Deploy docker image into Artifact Registry
1313
run: |
14-
case "${{ inputs.deploy-channel }}" in
14+
case "${INPUTS_DEPLOY_CHANNEL}" in
1515
stable)
1616
# Stable version tag : X.Y.Z-<amd64|arm64>
17-
SEMVER=$(echo ${{ github.ref_name }} | grep -oE '[0-9]+.[0-9]+.[0-9]+')
18-
TAG="${SEMVER}-${{ inputs.arch }}"
17+
SEMVER=$(echo ${GITHUB_REF_NAME} | grep -oE '[0-9]+.[0-9]+.[0-9]+')
18+
TAG="${SEMVER}-${INPUTS_ARCH}"
1919
;;
2020
unstable)
2121
# Unstable version tag : X.Y-<Github SHA 8 digit>-<amd64|arm64>
22-
SEMVER=$(echo ${{ github.ref_name }} | grep -oE '[0-9]+.[0-9]+')
22+
SEMVER=$(echo ${GITHUB_REF_NAME} | grep -oE '[0-9]+.[0-9]+')
2323
SHORT_SHA=$(echo ${{ github.sha }} | cut -c1-8)
24-
TAG="${SEMVER}-${SHORT_SHA}-${{ inputs.arch }}"
24+
TAG="${SEMVER}-${SHORT_SHA}-${INPUTS_ARCH}"
2525
;;
2626
nightly)
2727
# Nightly version tag : gitYYYYMMDDHHMM-<Github SHA 8 digit>-<amd64|arm64>
2828
SHORT_SHA=$(echo ${{ github.sha }} | cut -c1-8)
29-
TAG="git${{ inputs.yyyymmddhhmm }}-${SHORT_SHA}-${{ inputs.arch }}"
29+
TAG="git${INPUTS_YYYYMMDDHHMM}-${SHORT_SHA}-${INPUTS_ARCH}"
3030
;;
3131
*)
3232
exit 1
@@ -37,3 +37,7 @@ runs:
3737
docker tag cuttlefish-orchestration ${REMOTE_IMAGE_TAG}
3838
docker push ${REMOTE_IMAGE_TAG}
3939
shell: bash
40+
env:
41+
INPUTS_DEPLOY_CHANNEL: ${{ inputs.deploy-channel }}
42+
INPUTS_ARCH: ${{ inputs.arch }}
43+
INPUTS_YYYYMMDDHHMM: ${{ inputs.yyyymmddhhmm }}

.github/actions/mount-bazel-cache/action.yaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,15 @@ runs:
1111
- name: Load cache config
1212
run: |
1313
cat .config/cache-config.env >> $GITHUB_ENV
14-
echo "JOB_HASH=$(yq . .github/actions/${{ inputs.action-name }}/action.yaml | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV
14+
echo "JOB_HASH=$(yq . .github/actions/${INPUTS_ACTION_NAME}/action.yaml | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV
1515
shell: bash
16+
env:
17+
INPUTS_ACTION_NAME: ${{ inputs.action-name }}
1618
- name: Generate cache key prefix
17-
run: echo "CACHE_KEY_PREFIX=${{ runner.os }}-${{ runner.arch }}-bazel-disk-cache-${{ env.CACHE_VERSION }}-${{ inputs.action-name }}-${{ env.JOB_HASH }}" >> $GITHUB_ENV
19+
run: echo "CACHE_KEY_PREFIX=${{ runner.os }}-${{ runner.arch }}-bazel-disk-cache-${CACHE_VERSION}-${INPUTS_ACTION_NAME}-${JOB_HASH}" >> $GITHUB_ENV
1820
shell: bash
21+
env:
22+
INPUTS_ACTION_NAME: ${{ inputs.action-name }}
1923
- name: Restore cache
2024
if: inputs.writable != 'true'
2125
uses: actions/cache/restore@v4

.github/workflows/update-cache-and-deployment.yaml

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ jobs:
2323
id: yyyymmddhhmm
2424
run: echo "time=$(date -u +'%Y%m%d%H%M')" >> $GITHUB_OUTPUT
2525
- name: Echo YYYYMMDDHHMM
26-
run: echo ${{ steps.yyyymmddhhmm.outputs.time }}
26+
run: echo ${STEPS_YYYYMMDDHHMM_OUTPUTS_TIME}
27+
env:
28+
STEPS_YYYYMMDDHHMM_OUTPUTS_TIME: ${{ steps.yyyymmddhhmm.outputs.time }}
2729
update-cvd-test-bazel-cache:
2830
if: inputs.update-cache
2931
runs-on: ubuntu-24.04
@@ -119,7 +121,9 @@ jobs:
119121
- name: Checkout repository
120122
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
121123
- name: Build docker image
122-
run: container/image-builder.sh -m ${{ inputs.deploy-channel }}
124+
run: container/image-builder.sh -m ${INPUTS_DEPLOY_CHANNEL}
125+
env:
126+
INPUTS_DEPLOY_CHANNEL: ${{ inputs.deploy-channel }}
123127
- name: Authentication on GCP project android-cuttlefish-artifacts
124128
uses: 'google-github-actions/auth@v3'
125129
with:
@@ -145,7 +149,9 @@ jobs:
145149
- name: Checkout repository
146150
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
147151
- name: Build docker image
148-
run: container/image-builder.sh -m ${{ inputs.deploy-channel }}
152+
run: container/image-builder.sh -m ${INPUTS_DEPLOY_CHANNEL}
153+
env:
154+
INPUTS_DEPLOY_CHANNEL: ${{ inputs.deploy-channel }}
149155
- name: Authentication on GCP project android-cuttlefish-artifacts
150156
uses: 'google-github-actions/auth@v3'
151157
with:
@@ -182,32 +188,35 @@ jobs:
182188
password: '${{ secrets.artifact-registry-uploader-json-creds }}'
183189
- name: Deploy manifests
184190
run: |
185-
case "${{ inputs.deploy-channel }}" in
191+
case "${INPUTS_DEPLOY_CHANNEL}" in
186192
stable)
187193
# Stable version tag : X.Y.Z
188-
SEMVER=$(echo ${{ github.ref_name }} | grep -oE '[0-9]+.[0-9]+.[0-9]+')
194+
SEMVER=$(echo ${GITHUB_REF_NAME} | grep -oE '[0-9]+.[0-9]+.[0-9]+')
189195
TAG="${SEMVER}"
190196
;;
191197
unstable)
192198
# Unstable version tag : X.Y-<Github SHA 8 digit>
193-
SEMVER=$(echo ${{ github.ref_name }} | grep -oE '[0-9]+.[0-9]+')
199+
SEMVER=$(echo ${GITHUB_REF_NAME} | grep -oE '[0-9]+.[0-9]+')
194200
SHORT_SHA=$(echo ${{ github.sha }} | cut -c1-8)
195201
TAG="${SEMVER}-${SHORT_SHA}"
196202
;;
197203
nightly)
198204
# Nightly version tag : gitYYYYMMDDHHMM-<Github SHA 8 digit>
199205
SHORT_SHA=$(echo ${{ github.sha }} | cut -c1-8)
200-
TAG="git${{ needs.set-variables.outputs.yyyymmddhhmm }}-${SHORT_SHA}"
206+
TAG="git${NEEDS_SET_VARIABLES_OUTPUTS_YYYYMMDDHHMM}-${SHORT_SHA}"
201207
;;
202208
*)
203209
exit 1
204210
;;
205211
esac
206212
IMAGE=us-docker.pkg.dev/android-cuttlefish-artifacts/cuttlefish-orchestration/cuttlefish-orchestration
207213
208-
for MANIFEST_TAG in ${TAG} ${{ inputs.deploy-channel }}; do
214+
for MANIFEST_TAG in ${TAG} ${INPUTS_DEPLOY_CHANNEL}; do
209215
docker manifest create ${IMAGE}:${MANIFEST_TAG} \
210216
--amend ${IMAGE}:${TAG}-amd64 \
211217
--amend ${IMAGE}:${TAG}-arm64
212218
docker manifest push ${IMAGE}:${MANIFEST_TAG}
213219
done
220+
env:
221+
INPUTS_DEPLOY_CHANNEL: ${{ inputs.deploy-channel }}
222+
NEEDS_SET_VARIABLES_OUTPUTS_YYYYMMDDHHMM: ${{ needs.set-variables.outputs.yyyymmddhhmm }}

0 commit comments

Comments
 (0)