Skip to content

Commit 3d34234

Browse files
authored
Workflow file cleanup. (#357)
1. In `actions/checkout` steps, explictly set `persist-credentials`. 2. Don't use workflow expressions inline in Bash scripts to avoid string escaping problems.
1 parent a24edad commit 3d34234

9 files changed

+32
-10
lines changed

.github/workflows/binary-build.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ jobs:
3737
path: repo
3838
# Patch releases need the full history to find the latest tag.
3939
fetch-depth: ${{ inputs.publishType == 'patch' && '0' || '1' }}
40+
persist-credentials: false
4041

4142
- name: setup go 1.x
4243
uses: actions/setup-go@v5
@@ -125,7 +126,7 @@ jobs:
125126
IS_LATEST_RELEASE=false
126127
127128
# Create version suffix.
128-
case "${{ inputs.publishType }}" in
129+
case "$PUBLISH_TYPE" in
129130
"official")
130131
PRERELEASE_PARAM="IMAGE_CUSTOMIZER_VERSION_PREVIEW="
131132
IS_LATEST_RELEASE="true"
@@ -162,6 +163,8 @@ jobs:
162163
163164
# Print version.
164165
echo "Version: $PACKAGE_VERSION"
166+
env:
167+
PUBLISH_TYPE: ${{ inputs.publishType }}
165168

166169
- name: Setup Notation CLI
167170
uses: notaryproject/notation-action/setup@v1
@@ -173,9 +176,11 @@ jobs:
173176
./repo/toolkit/tools/imagecustomizer/container/notation/notation-setup.sh
174177
175178
CONTAINER_TAG="imagecustomizer:build"
176-
./repo/toolkit/tools/imagecustomizer/container/build-container.sh -t "$CONTAINER_TAG" -a "${{ inputs.arch }}" -b
179+
./repo/toolkit/tools/imagecustomizer/container/build-container.sh -t "$CONTAINER_TAG" -a "$ARCH" -b
177180
178181
docker image save "$CONTAINER_TAG" | gzip > "imagecustomizer.tar.gz"
182+
env:
183+
ARCH: ${{ inputs.arch }}
179184

180185
- name: Upload version artifact
181186
if: inputs.arch == 'amd64'

.github/workflows/docs-build.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ jobs:
1515
steps:
1616
- name: Checkout
1717
uses: actions/checkout@v4
18+
with:
19+
persist-credentials: false
1820

1921
- name: Setup ruby
2022
uses: ruby/setup-ruby@4a9ddd6f338a97768b8006bf671dfbad383215f4 # v1.207.0
@@ -29,17 +31,21 @@ jobs:
2931
uses: actions/configure-pages@v5
3032

3133
- name: Build with Jekyll
32-
run: bundle exec jekyll build --baseurl "${{ steps.pages.outputs.base_path }}"
34+
run: bundle exec jekyll build --baseurl "$PAGES_PATH"
3335
working-directory: ./docs
36+
env:
37+
PAGES_PATH: ${{ steps.pages.outputs.base_path }}
3438

3539
- name: Check links
3640
run: |
3741
bundle exec htmlproofer \
3842
--disable-external \
3943
--assume_extension '.html' \
40-
--swap-urls '^${{ steps.pages.outputs.base_path }}/:/' \
44+
--swap-urls "^${PAGES_PATH}/:/" \
4145
./_site
4246
working-directory: ./docs
47+
env:
48+
PAGES_PATH: ${{ steps.pages.outputs.base_path }}
4349

4450
- name: Upload site assets as artifact
4551
id: deployment

.github/workflows/fork-release-branch.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ jobs:
2222
uses: actions/checkout@v4
2323
with:
2424
path: repo
25+
persist-credentials: true
2526

2627
- name: Download build artifacts
2728
uses: actions/download-artifact@v4

.github/workflows/imagecreator-tests-functional.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,13 @@ jobs:
4545
git
4646
4747
# grub2-pc is only available on x86.
48-
if [[ "${{ inputs.hostArch }}" == "amd64" ]]; then
48+
if [[ "$HOST_ARCH" == "amd64" ]]; then
4949
sudo tdnf install -y grub2-pc
5050
fi
5151
5252
sudo tdnf list installed
53+
env:
54+
HOST_ARCH: ${{ inputs.hostArch }}
5355

5456
- name: Install prerequisites (Ubuntu 24.04)
5557
if: inputs.hostDistro == 'ubuntu2404'
@@ -68,6 +70,7 @@ jobs:
6870
uses: actions/checkout@v4
6971
with:
7072
path: repo
73+
persist-credentials: false
7174

7275
- name: Test setup
7376
run: |

.github/workflows/open-bump-version-pr.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Copyright (c) Microsoft Corporation.
22
# Licensed under the MIT License.
33

4-
name: Fork release branch
4+
name: Open bump version PR
55

66
permissions:
77
# Create release branch and publish release.
@@ -26,6 +26,7 @@ jobs:
2626
uses: actions/checkout@v4
2727
with:
2828
path: repo
29+
persist-credentials: true
2930

3031
- name: Open bump version PR
3132
env:

.github/workflows/publish-container.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
path: out
2626

2727
- name: Login to GHCR
28-
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u "${{ github.actor }}" --password-stdin
28+
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u "${GITHUB_ACTOR}" --password-stdin
2929

3030
- name: Install cosign
3131
uses: sigstore/[email protected]

.github/workflows/publish-release.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ jobs:
2626
uses: actions/checkout@v4
2727
with:
2828
path: repo
29+
persist-credentials: true
2930

3031
- name: Download build artifacts
3132
uses: actions/download-artifact@v4
@@ -35,6 +36,7 @@ jobs:
3536
- name: Publish release
3637
env:
3738
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
39+
IS_LATEST_RELEASE: ${{ inputs.isLatestRelease }}
3840
run: |
3941
set -x
4042
@@ -52,9 +54,9 @@ jobs:
5254
mv ../out/binary-amd64/imagecustomizer.tar.gz ../release/imagecustomizer-amd64.tar.gz
5355
mv ../out/binary-arm64/imagecustomizer.tar.gz ../release/imagecustomizer-arm64.tar.gz
5456
55-
gh release create --latest="${{ inputs.isLatestRelease }}" --title "${TAG}" --notes "" "${TAG}" ../release/*
57+
gh release create --latest="$IS_LATEST_RELEASE" --title "${TAG}" --notes "" "${TAG}" ../release/*
5658
5759
# Push to stable branch.
58-
if [ "${{ inputs.isLatestRelease }}" == "true" ]; then
60+
if [ "$IS_LATEST_RELEASE" == "true" ]; then
5961
git push --force origin HEAD:stable
6062
fi

.github/workflows/tests-functional.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,13 @@ jobs:
5151
git azure-cli
5252
5353
# grub2-pc is only available on x86.
54-
if [[ "${{ inputs.hostArch }}" == "amd64" ]]; then
54+
if [[ "$HOST_ARCH" == "amd64" ]]; then
5555
sudo tdnf install -y grub2-pc
5656
fi
5757
5858
sudo tdnf list installed
59+
env:
60+
HOST_ARCH: ${{ inputs.hostArch }}
5961

6062
- name: Install prerequisites (Ubuntu 24.04)
6163
if: inputs.hostDistro == 'ubuntu2404'
@@ -83,6 +85,7 @@ jobs:
8385
uses: actions/checkout@v4
8486
with:
8587
path: repo
88+
persist-credentials: false
8689

8790
- name: Download base images
8891
run: |

.github/workflows/tests-vmtests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ jobs:
8686
uses: actions/checkout@v4
8787
with:
8888
path: repo
89+
persist-credentials: false
8990

9091
- name: Download base images
9192
run: |

0 commit comments

Comments
 (0)