Skip to content

Commit a0e4229

Browse files
author
Jack Yuan
committed
migrate some travis codes to github-action
1 parent 3f84113 commit a0e4229

2 files changed

Lines changed: 22 additions & 16 deletions

File tree

github-actionify.sh

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ update() {
7171
process() {
7272
cd "$1"
7373

74-
# -- GitHub Action sanity checks --
74+
# -- Git sanity checks --
7575

7676
repoSlug=$(xmllint --xpath '//*[local-name()="project"]/*[local-name()="scm"]/*[local-name()="connection"]' pom.xml|sed 's_.*github.com[:/]\(.*\)<.*_\1_')
7777
test "$repoSlug" && info "Repository = $repoSlug" || die 'Could not determine GitHub repository slug'
@@ -95,16 +95,14 @@ process() {
9595
# -- POM sanity checks --
9696

9797
parent=$(xmllint --xpath '//*[local-name()="project"]/*[local-name()="parent"]/*[local-name()="artifactId"]' pom.xml|sed 's/[^>]*>//'|sed 's/<.*//')
98-
echo $parent ##########################################
9998
if [ -z "$SKIP_PARENT_CHECK" ]
10099
then
101100
test "$parent" = "pom-scijava" ||
102101
die "Not pom-scijava parent: $parent. Run with -p flag to skip this check."
103102
fi
104103

105-
# https://docs.github.com/en/actions/managing-workflow-runs/adding-a-workflow-status-badge
104+
######################### CHANGE POM.XML??? #########################
106105
domain=$(grep "travis-ci\.[a-z]*/$repoSlug" pom.xml 2>/dev/null | sed 's/.*\(travis-ci\.[a-z]*\).*/\1/')
107-
echo $domain ##################################################
108106
test "$domain" &&
109107
info "Detected domain from pom.xml: $domain" ||
110108
die "No valid ciManagement section in pom.xml. Please add one, then try again."
@@ -191,17 +189,18 @@ EOL
191189
fi
192190

193191
# update the README
194-
if grep -q "travis-ci\.[a-zA-Z0-9/_-]*\.svg" README.md >/dev/null 2>&1
192+
# https://docs.github.com/en/actions/managing-workflow-runs/adding-a-workflow-status-badge
193+
if grep -q "github\.com\/[a-zA-Z0-9/_-]*\/actions/workflow/main.yml/badge.svg" README.md >/dev/null 2>&1
195194
then
196-
info "Updating README.md Travis badge"
197-
sed "s|travis-ci\.[a-zA-Z0-9/_-]*|$domain/$repoSlug|g" README.md >"$tmpFile"
198-
update README.md 'Travis: fix README.md badge link'
195+
info "Updating README.md GitHub Action badge"
196+
sed "s|github\.com\/[a-zA-Z0-9/_-]*|$domain/$repoSlug|g" README.md >"$tmpFile"
197+
update README.md 'GitHub Action: fix README.md badge link'
199198
else
200-
info "Adding Travis badge to README.md"
199+
info "Adding GitHub Action badge to README.md"
201200
echo "[![](https://$domain/$repoSlug.svg?branch=$defaultBranch)](https://$domain/$repoSlug)" >"$tmpFile"
202201
echo >>"$tmpFile"
203202
test -f README.md && cat README.md >>"$tmpFile"
204-
update README.md 'Travis: add badge to README.md'
203+
update README.md 'GitHub Action: add badge to README.md'
205204
fi
206205

207206
# encrypt key/value pairs in variables file
@@ -213,6 +212,7 @@ EOL
213212
'#'*) continue;;
214213
esac
215214
info "Encrypting ${p%%=*}"
215+
######################### TODO #########################
216216
yes | $EXEC travis encrypt --$mode "$p" --add env.global --repo "$repoSlug"
217217
test $? -eq 0 || die "Failed to encrypt variable '$p'"
218218
done <"$varsFile"
@@ -228,15 +228,17 @@ EOL
228228
if [ -z "$EXEC" ]
229229
then
230230
rm -f "$signingKeyDestFile.enc"
231+
######################### TODO #########################
232+
# https://docs.github.com/en/github/authenticating-to-github/generating-a-new-gpg-key
231233
encryptOutput=$(travis encrypt-file --$mode "$signingKeySourceFile" "$signingKeyDestFile.enc" --repo "$repoSlug")
232234
test $? -eq 0 || die "Failed to encrypt signing key."
233235
encryptResult=$(echo "$encryptOutput" | grep openssl)
234236
test "$encryptResult" || die "No openssl variables emitted."
235237
key=$(echo "$encryptResult" | cut -d' ' -f4)
236238
iv=$(echo "$encryptResult" | cut -d' ' -f6)
237-
sed -i.bak "s/\(sh travis-build.sh\)/\1 $key $iv/" "$travisBuildScript"
238-
rm -f "$travisBuildScript.bak"
239-
git add "$travisBuildScript" "$signingKeyDestFile.enc"
239+
sed -i.bak "s/\(sh github-action-build.sh\)/\1 $key $iv/" "$gitactionBuildScript"
240+
rm -f "$gitactionBuildScript.bak"
241+
git add "$gitactionBuildScript" "$signingKeyDestFile.enc"
240242
git commit -m "GitHub Action: add encrypted GPG signing keypair"
241243
fi
242244
else
@@ -251,6 +253,7 @@ test -d "$credentialsDir" ||
251253
"Please contact a SciJava administrator to receive a copy of this content."
252254

253255
# check prerequisites
256+
######################### TODO #########################
254257
check git sed cut perl xmllint travis
255258

256259
# parse arguments

github-javadoc.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ keep_alive() {
3737
wait "$pid"
3838
}
3939

40+
######################## TODO ########################
4041
if [ "$TRAVIS_SECURE_ENV_VARS" = true \
4142
-a "$TRAVIS_PULL_REQUEST" = false \
4243
-a "$TRAVIS_BRANCH" = master ]
@@ -48,7 +49,7 @@ then
4849
# Populate the settings.xml configuration.
4950
mkdir -p "$HOME/.m2"
5051
settingsFile="$HOME/.m2/settings.xml"
51-
customSettings=.travis/settings.xml
52+
customSettings=.github/settings.xml
5253
if [ -f "$customSettings" ]
5354
then
5455
cp "$customSettings" "$settingsFile"
@@ -90,13 +91,14 @@ EOL
9091
echo &&
9192
echo "== Configuring environment ==" &&
9293

93-
# Configure SSH. The file .travis/javadoc.scijava.org.enc must contain
94+
# Configure SSH. The file .github/javadoc.scijava.org.enc must contain
9495
# an encrypted private RSA key for communicating with the git remote.
9596
mkdir -p "$HOME/.ssh" &&
96-
openssl aes-256-cbc -K "$openssl_key" -iv "$openssl_iv" -in '.travis/javadoc.scijava.org.enc' -out "$HOME/.ssh/id_rsa" -d &&
97+
openssl aes-256-cbc -K "$openssl_key" -iv "$openssl_iv" -in '.github/javadoc.scijava.org.enc' -out "$HOME/.ssh/id_rsa" -d &&
9798
chmod 400 "$HOME/.ssh/id_rsa" &&
9899

99100
# Configure git settings.
101+
######################## TODO ########################
100102
git config --global user.email "travis@travis-ci.com" &&
101103
git config --global user.name "Travis CI" &&
102104

@@ -117,6 +119,7 @@ EOL
117119

118120
test "$success" || exit 1
119121

122+
######################## TODO ########################
120123
git commit -m "Update $project javadocs (Travis build $TRAVIS_BUILD_NUMBER)"
121124
git pull --rebase &&
122125
git push -q origin gh-pages > /dev/null || exit 2

0 commit comments

Comments
 (0)