-
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GitHub action: Add config option to overwrite history.
- Loading branch information
1 parent
9cdd617
commit eb1605d
Showing
3 changed files
with
35 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,13 +5,15 @@ zulip_organization_url=$1 | |
zulip_bot_email=$2 | ||
zulip_bot_api_key=$3 | ||
github_personal_access_token=$4 | ||
delete_history=$5 | ||
|
||
checked_out_repo_path="$(pwd)" | ||
html_dir_path=$checked_out_repo_path | ||
json_dir_path="${checked_out_repo_path}/zulip_json" | ||
_layouts_path="${checked_out_repo_path}/_layouts" | ||
img_dir_path="${checked_out_repo_path}/assets/img" | ||
streams_config_file_path="${checked_out_repo_path}/streams.yaml" | ||
initial_sha="$(git rev-parse HEAD)" | ||
|
||
if [ ! -f $streams_config_file_path ]; then | ||
echo "Missing streams.yaml file." | ||
|
@@ -75,14 +77,35 @@ cd ${checked_out_repo_path} | |
|
||
git checkout master | ||
|
||
git fetch origin | ||
|
||
current_sha="$(git rev-parse origin/master)" | ||
|
||
if [[ "$current_sha" != "$initial_sha" ]] | ||
then | ||
echo "Archive update failed, commits have been added while processing" | ||
exit 1 | ||
fi | ||
|
||
echo "delete history: $delete_history" | ||
|
||
if [[ "$delete_history" == "true" ]] | ||
then | ||
echo "resetting" | ||
rm -rf .git | ||
git init | ||
fi | ||
|
||
git config --global user.email "[email protected]" | ||
git config --global user.name "Archive Bot" | ||
|
||
git add -A | ||
git commit -m "Update archive." | ||
|
||
git remote set-url --push origin https://${GITHUB_ACTOR}:${github_personal_access_token}@github.com/${GITHUB_REPOSITORY} | ||
git remote add origin2 https://${GITHUB_ACTOR}:${github_personal_access_token}@github.com/${GITHUB_REPOSITORY} | ||
|
||
git push origin2 master -f | ||
|
||
git push origin master --force | ||
echo "pushed" | ||
|
||
echo "Zulip Archive published/updated in ${github_pages_url}" |