Skip to content

Commit 2d08c09

Browse files
Use single GitHub Secret for deployment
Testing with my local repo first
1 parent b338cd8 commit 2d08c09

File tree

3 files changed

+15
-27
lines changed

3 files changed

+15
-27
lines changed

.github/workflows/release-to-publish.yml

+12-22
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,26 @@
11
# Whenever a release is published from a draft, this will update the
22
# master Arduino JSON file to add its new entry.
33

4-
# We keep the master JSON file in another repo, so we need to use a pre-set GH
5-
# SSH key to be able to push a change to the repo.
6-
7-
# At some point this should really be moved to the main repo to avoid this grief
4+
# We keep the master JSON file in another repo, so we need to use a pre-set
5+
# Deployment SSH key to be able to push a change to the repo.
86

97
#### Steps to follow when you need to make a new SSH key for upload (not
108
#### normally needed!)
119

12-
# We encrypt the id_rda (private key) using a key and IV generated randomly:
13-
# openssl enc -nosalt -aes-256-cbc -pbkdf2 -k "$(openssl rand -base64 100 | sed s/=//)" -P
14-
# > key = <long string of hex>
15-
# > iv = <long string of hex>
10+
# Generate a new SSH key private/public pair
1611

17-
# Set that key and IV strings are set as secrets in the *Arduino repo* GitHub
18-
# CI Secrets object as GHKEY and GHIV.
12+
# ssh-keygen -t rsa -b 4096 -C "[email protected]" -f ./deploy_rsa
1913

20-
# Now make a SSH key using ssh-keygen (do not use your own, make a new one!)
21-
# ssh-keygen ...
14+
# Upload deploy_rsa.pub to the *ESP8266.GITHUB.IO* repo as a deployment key
2215

23-
# Upload the id_rsa.pub (public key) to the GH.IO GitHub as a *deploy key*
24-
# (https://github.com/esp8266/esp8266.github.io->Settings->Deploy Keys->Add Key)
25-
# DO NOT USE Settings->SSH and GPG Keys->New SSH Key because that allows
26-
# full access to all repos owned by the user, while a Deploy Key only allows
27-
# access to a single repo.
16+
# Convert the private key to base64 (to remove line breaks and allow easier
17+
# usage in the script as an environment variable)
2818

29-
# Encrypt the private part of the key using the key and IV above and commit the change
30-
# openssl enc -aes-256-cbc -K <key> -iv <iv> -in id_rsa -out package/esp8266_github_io_deploy.enc
31-
# git add package/esp8266_github_io_deploy.enc
19+
# base64.exe -w 0 < deploy_rsa > deploy_rsa.b64
3220

21+
# Copy the contents of the .b64 file to the clipboard, make a new GitHub
22+
# secret in the ESP8266/Arduino repo called "GHCI_DEPLOY_KEY" and paste
23+
# the B64 code into the variable.
3324

3425
name: ESP8266 Arduino Release Publisher
3526

@@ -56,8 +47,7 @@ jobs:
5647
TRAVIS_BUILD_DIR: ${{ github.workspace }}
5748
BUILD_TYPE: package
5849
CI_GITHUB_API_KEY: ${{ secrets.GITHUB_TOKEN }}
59-
GHKEY: ${{ secrets.GHKEY }}
60-
GHIV: ${{ secrets.GHIV }}
50+
GHCI_DEPLOY_KEY: ${{ secrets.GHCI_DEPLOY_KEY }}
6151
run: |
6252
bash ./tests/ci/build_package.sh
6353
# Only the regenerated JSON file will be used, but it's simpler

package/arduino-esp8266-travis.enc

-432 Bytes
Binary file not shown.

package/deploy_package_index.sh

+3-5
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@ cd $(dirname "$0")
77

88
set -e # Abort with error if anything here does not go as expected!
99

10-
# Decrypt and install SSH private key.
11-
# "encrypted_xxx_key" and "encrypted_xxx_iv" are environment variables
12-
# known to Travis CI builds.
13-
openssl enc -d -aes-256-cbc -K $GHKEY -iv $GHIV -in esp8266_github_io_deploy.enc -out esp8266_github_io_deploy
10+
# Install SSH private key from a GH Secret
11+
echo $GHCI_DEPLOY_KEY | base64 -d > esp8266_github_io_deploy
1412
eval "$(ssh-agent -s)"
1513
chmod 600 esp8266_github_io_deploy
1614
ssh-add esp8266_github_io_deploy
@@ -20,7 +18,7 @@ echo -e "Host github.com\nStrictHostKeyChecking no\n" >> ~/.ssh/config
2018
chmod go-w ~/.ssh/config
2119

2220
# Clone the Github pages repository
23-
git clone [email protected]:esp8266/esp8266.github.io.git
21+
git clone [email protected]:earlephilhower/esp8266.github.io.git
2422
pushd esp8266.github.io
2523

2624
# Update the package index

0 commit comments

Comments
 (0)