Skip to content

Commit

Permalink
Adapt tools/test-fork.sh to the current GitHub Action workflows. (#1384)
Browse files Browse the repository at this point in the history
* Make the test-fork.sh script correctly remove the Codecov step from build.yml.

Signed-off-by: hhiroshell <[email protected]>

* Make the test-fork.sh script add the necessary permissions for pushing images to ghcr.io in the build and post-release workflows.

Signed-off-by: hhiroshell <[email protected]>

---------

Signed-off-by: hhiroshell <[email protected]>
  • Loading branch information
hhiroshell authored Jul 18, 2024
1 parent df6be88 commit 9f262b3
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions tools/test-fork.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,22 @@ if [[ $registry != "index.docker.io" ]]; then
sed -i '' "s/username: \${{ secrets.DOCKER_USERNAME }}/login-server: $registry\n username: $username/g" .github/workflows/*.yml
fi

# If using ghcr.io, we don't need to set the DOCKER_* secrets. Update the login action to use GitHub token instead.
if [[ $registry == *"ghcr.io"* ]]; then
# If using ghcr.io, we don't need to set the DOCKER_* secrets. Update the login action to use GitHub token instead.
echo "Updating login action to use GitHub token for ghcr.io"
sed -i '' "s/secrets.DOCKER_PASSWORD/secrets.GITHUB_TOKEN/g" .github/workflows/*.yml

echo "Adding workflow permissions to push images to ghcr.io"
LF=$'\n'
sed -i '' "/ id-token: write/ a\\
contents: read\\
packages: write\\
attestations: write${LF}" .github/workflows/build.yml
sed -i '' "/ id-token: write/ a\\
contents: read\\
packages: write\\
attestations: write${LF}" .github/workflows/post-release.yml
LF=""
fi

echo "Removing arm tests (these require a self-hosted runner)"
Expand All @@ -51,7 +63,7 @@ if [[ -z $2 ]]; then
sed -i '' "s/make acceptance/echo acceptance/g" .github/workflows/*.yml
echo "$(sed '/pack-acceptance/,$d' .github/workflows/build.yml)" > .github/workflows/build.yml
echo "Removing Codecov"
sed -i '' "/- name: Upload coverage to Codecov/,+6d" .github/workflows/build.yml
sed -i '' "/- name: Upload coverage to Codecov/,+7d" .github/workflows/build.yml
sed -i '' "/- name: Prepare Codecov/,+6d" .github/workflows/build.yml
else
echo "Retaining tests"
Expand Down

0 comments on commit 9f262b3

Please sign in to comment.