Skip to content

Commit

Permalink
Updates the secret with new build details
Browse files Browse the repository at this point in the history
  • Loading branch information
typhonius committed Oct 13, 2024
1 parent 9d32919 commit 6dadc52
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/ddn-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,37 @@ jobs:
body: `Supergraph build was successful! 🎉\n\n**Build URL:** [${buildUrl}](${buildUrl})\n**Console URL:** [${consoleUrl}](${consoleUrl})\n**Commit ID:** ${commitId}`
})
- name: Encrypt and update ENV_CLOUD_DEFAULT
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const fs = require('fs');
const sodium = require('tweetsodium');
const secretValue = fs.readFileSync('.env.cloud.default', 'utf8').trim();
const { data: publicKeyData } = await github.rest.actions.getRepoPublicKey({
owner: context.repo.owner,
repo: context.repo.repo,
});
const publicKey = publicKeyData.key;
const keyId = publicKeyData.key_id;
const messageBytes = Buffer.from(secretValue);
const keyBytes = Buffer.from(publicKey, 'base64');
const encryptedBytes = sodium.seal(messageBytes, keyBytes);
const encryptedValue = Buffer.from(encryptedBytes).toString('base64');
await github.rest.actions.createOrUpdateRepoSecret({
owner: context.repo.owner,
repo: context.repo.repo,
secret_name: 'ENV_CLOUD_DEFAULT',
encrypted_value: encryptedValue,
key_id: keyId
});
test:
runs-on: ubuntu-latest

Expand Down

0 comments on commit 6dadc52

Please sign in to comment.