Skip to content

Commit ba5a492

Browse files
authored
actions: Add 'archive_branch' option to the GitHub Action.
This is important with the change from master => main for default branches.
1 parent 669d870 commit ba5a492

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

action.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ inputs:
1414
github_personal_access_token:
1515
description: 'GitHub personal access token'
1616
required: true
17+
archive_branch:
18+
description: 'Branch where to commit archive files (should coincide with GH Pages branch)'
19+
# legacy
20+
required: false
21+
default: 'master'
1722
runs:
1823
using: 'docker'
1924
image: 'Dockerfile'
@@ -23,3 +28,4 @@ runs:
2328
- ${{ inputs.zulip_bot_key }}
2429
- ${{ inputs.github_personal_access_token }}
2530
- ${{ inputs.delete_history }}
31+
- ${{ inputs.archive_branch }}

entrypoint.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ zulip_bot_email=$2
66
zulip_bot_api_key=$3
77
github_personal_access_token=$4
88
delete_history=$5
9+
archive_branch=$6
910

1011
checked_out_repo_path="$(pwd)"
1112
html_dir_path=$checked_out_repo_path
@@ -36,7 +37,7 @@ auth_header="Authorization: Bearer ${github_personal_access_token}"
3637
accept_header="Accept: application/vnd.github.switcheroo-preview+json"
3738
page_api_url="https://api.github.com/repos/${GITHUB_REPOSITORY}/pages"
3839
# Enable GitHub pages
39-
curl -H "$auth_header" -H "$accept_header" --data "source=master" "$page_api_url"
40+
curl -H "$auth_header" -H "$accept_header" --data "source=${archive_branch}" "$page_api_url"
4041

4142
print_site_url_code="import sys, json; print(json.load(sys.stdin)['html_url'])"
4243
github_pages_url_with_trailing_slash=$(curl -H "${auth_header}" $page_api_url | python3 -c "${print_site_url_code}")
@@ -75,11 +76,11 @@ python3 archive.py -b
7576

7677
cd ${checked_out_repo_path}
7778

78-
git checkout master
79+
git checkout $archive_branch
7980

8081
git fetch origin
8182

82-
current_sha="$(git rev-parse origin/master)"
83+
current_sha="$(git rev-parse origin/${archive_branch})"
8384

8485
if [[ "$current_sha" != "$initial_sha" ]]
8586
then
@@ -104,7 +105,7 @@ git commit -m "Update archive."
104105

105106
git remote add origin2 https://${GITHUB_ACTOR}:${github_personal_access_token}@github.com/${GITHUB_REPOSITORY}
106107

107-
git push origin2 master -f
108+
git push origin2 $archive_branch -f
108109

109110
echo "pushed"
110111

0 commit comments

Comments
 (0)