-
Notifications
You must be signed in to change notification settings - Fork 112
/
test-fork.sh
executable file
·71 lines (60 loc) · 2.4 KB
/
test-fork.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/bash
# $1 - registry repo name
# $2 - enable tests
echo "Parse registry: $1"
firstPart=$(echo $1 | cut -d/ -f1)
secondPart=$(echo $1 | cut -d/ -f2)
thirdPart=$(echo $1 | cut -d/ -f3)
registry=""
username=""
reponame=""
if [[ -z $thirdPart ]]; then # assume Docker Hub
registry="index.docker.io"
username=$firstPart
reponame=$secondPart
else
registry=$firstPart
username=$secondPart
reponame=$thirdPart
fi
echo "Using registry $registry and username $username"
if [[ $reponame != "lifecycle" ]]; then
echo "Repo name must be 'lifecycle'"
exit 1
fi
echo "Using own registry account (assumes DOCKER_PASSWORD and DOCKER_USERNAME have been added to GitHub secrets, if not using ghcr.io)"
sed -i '' "s/buildpacksio\/lifecycle/$registry\/$username\/lifecycle/g" .github/workflows/*.yml
if [[ $registry != "index.docker.io" ]]; then
echo "Updating login action to specify the login server"
sed -i '' "s/username: \${{ secrets.DOCKER_USERNAME }}/login-server: $registry\n username: $username/g" .github/workflows/*.yml
fi
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)"
sed -i '' "/test-linux-arm64:/,+14d" .github/workflows/build.yml
sed -i '' "/test-linux-arm64/d" .github/workflows/build.yml
if [[ -z $2 ]]; then
echo "Removing all tests to make things faster"
sed -i '' "s/make test/echo test/g" .github/workflows/*.yml
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/,+7d" .github/workflows/build.yml
sed -i '' "/- name: Prepare Codecov/,+6d" .github/workflows/build.yml
else
echo "Retaining tests"
fi