Skip to content

Commit

Permalink
feat: add pinning to crust (#151)
Browse files Browse the repository at this point in the history
  • Loading branch information
sakulstra authored Nov 22, 2021
1 parent e81e955 commit 2e10652
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 60 deletions.
22 changes: 18 additions & 4 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,27 @@ jobs:
- name: build
run: npm run build

- name: deploy
id: deploy
- name: pinata
id: pinata
env:
PINATA_API_KEY: ${{ secrets.PINATA_API_KEY }}
PINATA_SECRET_KEY: ${{ secrets.PINATA_SECRET_KEY }}
PIN_ALIAS: staging
run: node scripts/pin-pinata.js

- name: crust
uses: crustio/ipfs-crust-action@f51bf12d352d230e12bfd8fa00b07f1f6c7aa735
continue-on-error: true
timeout-minutes: 2
with:
cid: ${{ steps.pinata.outputs.hash }}
seeds: ${{ secrets.CRUST_SEEDS }}

- name: deploy
id: deploy
env:
CF_API_TOKEN: ${{ secrets.CF_API_TOKEN }}
CF_ZONE_ID: ${{ secrets.CF_ZONE_ID }}
PIN_ALIAS: staging
HASH: ${{ steps.pinata.outputs.hash }}
CF_DEPLOYMENT_DOMAIN: staging.aave.com
run: npm run pinata:ipfs-publish
run: node scripts/update-cloudflare.js
22 changes: 18 additions & 4 deletions .github/workflows/deploy_prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,27 @@ jobs:
- name: build
run: npm run build

- name: Pinata upload
id: deploy
- name: pinata
id: pinata
env:
PINATA_API_KEY: ${{ secrets.PINATA_API_KEY }}
PINATA_SECRET_KEY: ${{ secrets.PINATA_SECRET_KEY }}
PIN_ALIAS: staging
run: node scripts/pin-pinata.js

- name: crust
uses: crustio/ipfs-crust-action@f51bf12d352d230e12bfd8fa00b07f1f6c7aa735
continue-on-error: true
timeout-minutes: 2
with:
cid: ${{ steps.pinata.outputs.hash }}
seeds: ${{ secrets.CRUST_SEEDS }}

- name: deploy
id: deploy
env:
CF_API_TOKEN: ${{ secrets.CF_API_TOKEN }}
CF_ZONE_ID: ${{ secrets.CF_ZONE_ID }}
PIN_ALIAS: production
HASH: ${{ steps.pinata.outputs.hash }}
CF_DEPLOYMENT_DOMAIN: app.aave.com
run: npm run pinata:ipfs-publish
run: node scripts/update-cloudflare.js
10 changes: 5 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
deploy_ipfs:
runs-on: ubuntu-latest
outputs:
uri: ${{ steps.deploy.outputs.uri }}
uri: ${{ steps.pinata.outputs.uri }}
steps:
- uses: actions/checkout@v2

Expand All @@ -29,13 +29,13 @@ jobs:
- name: build
run: npm run build

- name: deploy
id: deploy
- name: pinata
id: pinata
env:
PINATA_API_KEY: ${{ secrets.PINATA_API_KEY }}
PINATA_SECRET_KEY: ${{ secrets.PINATA_SECRET_KEY }}
PIN_ALIAS: "${{ format('pull_request_{0}', github.head_ref) }}"
run: npm run pinata:ipfs-publish
run: node scripts/pin-pinata.js

- uses: actions/github-script@v5
with:
Expand All @@ -44,7 +44,7 @@ jobs:
issue_number: context.payload.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'Preview link: ${{steps.deploy.outputs.uri}}'
body: 'Preview link: ${{steps.pinata.outputs.uri}}'
})
test:
Expand Down
24 changes: 0 additions & 24 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@
"web3-provider-engine": "^16.0.3"
},
"devDependencies": {
"@actions/core": "^1.6.0",
"@graphql-codegen/cli": "^2.2.1",
"@graphql-codegen/fragment-matcher": "^3.1.0",
"@graphql-codegen/typescript": "^2.2.4",
Expand Down
5 changes: 4 additions & 1 deletion scripts/helpers/pinata.js → scripts/pin-pinata.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,7 @@ const cleanupAndPin = async () => {
}
};

module.exports = cleanupAndPin;
cleanupAndPin().then((hash) => {
console.log(`::set-output name=hash::${hash}`);
console.log(`::set-output name=uri::https://cloudflare-ipfs.com/ipfs/${hash}`);
});
19 changes: 0 additions & 19 deletions scripts/publish.js

This file was deleted.

16 changes: 14 additions & 2 deletions scripts/helpers/cloudflare.js → scripts/update-cloudflare.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const updateOrCreateRecord = async (name, type, _payload) => {

const updateCloudFlareRecord = async (hash, domain) => {
console.log(`domain to update - https://${domain}`);

if (domain != 'app.aave.com') {
console.log('updating CNAME record');
await updateOrCreateRecord(domain, 'CNAME', {
Expand All @@ -64,4 +64,16 @@ const updateCloudFlareRecord = async (hash, domain) => {
console.log('done');
};

module.exports = updateCloudFlareRecord;
const publish = async () => {
const domain = process.env.CF_DEPLOYMENT_DOMAIN;
const hash = process.env.HASH;
if (domain && hash) {
console.log(`trying to update DNS for ${domain} with ${hash}`);
await updateCloudFlareRecord(hash, domain);
} else {
console.log('no cloudflare domain specified, skipping DNS update');
}
process.exit(0);
};

publish();

0 comments on commit 2e10652

Please sign in to comment.