diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index f308e2721..197db98cf 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -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 diff --git a/.github/workflows/deploy_prod.yml b/.github/workflows/deploy_prod.yml index 4dd51785f..56006cdef 100644 --- a/.github/workflows/deploy_prod.yml +++ b/.github/workflows/deploy_prod.yml @@ -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 diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d92b30bbf..7628ade99 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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 @@ -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: @@ -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: diff --git a/package-lock.json b/package-lock.json index b391ffb94..c2e393f25 100644 --- a/package-lock.json +++ b/package-lock.json @@ -444,24 +444,6 @@ "standard-version": "^9.1.0" } }, - "@actions/core": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.6.0.tgz", - "integrity": "sha512-NB1UAZomZlCV/LmJqkLhNTqtKfFXJZAUPcfl/zqG7EfsQdeUJtaWO98SGbuQ3pydJ3fHl2CvI/51OKYlCYYcaw==", - "dev": true, - "requires": { - "@actions/http-client": "^1.0.11" - } - }, - "@actions/http-client": { - "version": "1.0.11", - "resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-1.0.11.tgz", - "integrity": "sha512-VRYHGQV1rqnROJqdMvGUbY/Kn8vriQe/F9HR2AlYHzmKuM/p3kjNuXhmdBfcVgsvRWTz5C5XW5xvndZrVBuAYg==", - "dev": true, - "requires": { - "tunnel": "0.0.6" - } - }, "@apollo/client": { "version": "3.4.16", "resolved": "https://registry.npmjs.org/@apollo/client/-/client-3.4.16.tgz", @@ -40679,12 +40661,6 @@ "resolved": "https://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.0.tgz", "integrity": "sha1-oVe6QC2iTpv5V/mqadUk7tQpAaY=" }, - "tunnel": { - "version": "0.0.6", - "resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.6.tgz", - "integrity": "sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg==", - "dev": true - }, "tunnel-agent": { "version": "0.6.0", "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", diff --git a/package.json b/package.json index a78538d27..9a2ee243a 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/scripts/helpers/pinata.js b/scripts/pin-pinata.js similarity index 92% rename from scripts/helpers/pinata.js rename to scripts/pin-pinata.js index 2f8d8fc91..1b771fea9 100644 --- a/scripts/helpers/pinata.js +++ b/scripts/pin-pinata.js @@ -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}`); +}); diff --git a/scripts/publish.js b/scripts/publish.js deleted file mode 100644 index 2e6eb1a38..000000000 --- a/scripts/publish.js +++ /dev/null @@ -1,19 +0,0 @@ -const core = require('@actions/core'); -const updateCloudFlareRecord = require('./helpers/cloudflare'); -const cleanupAndPin = require('./helpers/pinata'); - -async function pinAndPublish() { - const hash = await cleanupAndPin(); - console.log(`Pinning was done successfully: https://cloudflare-ipfs.com/ipfs/${hash}`); - core.setOutput('uri', `https://cloudflare-ipfs.com/ipfs/${hash}`); - - const domain = process.env.CF_DEPLOYMENT_DOMAIN; - if (domain) { - await updateCloudFlareRecord(hash, domain); - } else { - console.log('no cloudflare domain specified, skipping DNS update'); - } - process.exit(0); -} - -pinAndPublish(); diff --git a/scripts/helpers/cloudflare.js b/scripts/update-cloudflare.js similarity index 84% rename from scripts/helpers/cloudflare.js rename to scripts/update-cloudflare.js index b7246e304..83cf374cc 100644 --- a/scripts/helpers/cloudflare.js +++ b/scripts/update-cloudflare.js @@ -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', { @@ -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();