Skip to content

Commit 2663c65

Browse files
committed
Add option to specify a new identity based on .pem secret.
1 parent e867b6c commit 2663c65

File tree

3 files changed

+35
-9
lines changed

3 files changed

+35
-9
lines changed

.github/workflows/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ jobs:
66
- uses: actions/checkout@v2
77
- uses: ./
88
with:
9-
dfx-version: 0.7.1
10-
vessel-version: 0.6.1
9+
dfx-version: 0.7.2
10+
vessel-version: 0.6.2
1111
- run: |
1212
dfx --version
1313
moc --version

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,23 @@ steps:
2020
vessel --version
2121
```
2222
23+
### Deploying
24+
25+
```yml
26+
runs-on: ubuntu-latest
27+
steps:
28+
- uses: actions/checkout@v2
29+
- uses: allusion-be/setup-dfx@main
30+
with:
31+
dfx-version: 0.7.2
32+
install-moc: false
33+
env:
34+
DFX_IDENTITY_PEM: ${{ secrets.DFX_IDENTITY_PEM }}
35+
- run: |
36+
dfx identity use action
37+
dfx deploy --network ic --no-wallet
38+
```
39+
2340
## Possible Improvements
2441
2542
1. Make use of the [manifest.json](https://sdk.dfinity.org/manifest.json) to check versions.

src/main.ts

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export async function run() {
1010
}
1111

1212
try {
13-
let dfxVersion = core.getInput('dfx-version');
13+
const dfxVersion = core.getInput('dfx-version');
1414
core.info(`Setup dfx version ${dfxVersion}`);
1515

1616
// Opt-out of having data collected about dfx usage.
@@ -20,27 +20,36 @@ export async function run() {
2020
cp.execSync(`echo y | DFX_VERSION=${dfxVersion} sh -ci "$(curl -fsSL https://sdk.dfinity.org/install.sh)"`);
2121
core.addPath('/home/runner/bin');
2222

23-
let dfxPath = await io.which('dfx');
23+
const dfxPath = await io.which('dfx');
2424
core.debug(dfxPath);
2525
infoExec(`${dfxPath} --version`);
2626

27+
// Setup identity.
28+
const id: string = process.env[`DFX_IDENTITY_PEM`] || '';
29+
if (id) {
30+
cp.execSync(`${dfxPath} identity new action`);
31+
cp.execSync(`chmod +w /home/runner/.config/dfx/identity/action/identity.pem`)
32+
cp.execSync(`echo "${id}" > /home/runner/.config/dfx/identity/action/identity.pem`);
33+
infoExec(`${dfxPath} identity list`);
34+
}
35+
2736
// Install dfx cache to get moc.
2837
if (core.getBooleanInput('install-moc')) {
2938
cp.execSync(`${dfxPath} cache install`);
30-
let cachePath = infoExec(`${dfxPath} cache show`).trim();
39+
const cachePath = infoExec(`${dfxPath} cache show`).trim();
3140
core.addPath(cachePath);
3241

33-
let mocPath = await io.which('moc');
42+
const mocPath = await io.which('moc');
3443
infoExec(`${mocPath} --version`);
3544
}
3645

3746
// Install vessel.
38-
let vesselVersion = core.getInput('vessel-version');
47+
const vesselVersion = core.getInput('vessel-version');
3948
if (vesselVersion) {
4049
cp.execSync(`curl -L https://github.com/dfinity/vessel/releases/download/v${vesselVersion}/vessel-linux64 > /home/runner/bin/vessel`);
4150
cp.execSync(`chmod +x /home/runner/bin/vessel`);
4251

43-
let vesselPath = await io.which('vessel');
52+
const vesselPath = await io.which('vessel');
4453
infoExec(`${vesselPath} --version`);
4554
}
4655
} catch (e) {
@@ -49,7 +58,7 @@ export async function run() {
4958
}
5059

5160
function infoExec(command: string) : string {
52-
let cmdStr = (cp.execSync(command) || '').toString();
61+
const cmdStr = (cp.execSync(command) || '').toString();
5362
core.info(cmdStr);
5463
return cmdStr;
5564
}

0 commit comments

Comments
 (0)