diff --git a/.env b/.env new file mode 100644 index 0000000..9f499d5 --- /dev/null +++ b/.env @@ -0,0 +1,2 @@ +GATSBY_WEBSITE_VERSION="1.0.0" +ASSET_PREFIX="" diff --git a/.env.production b/.env.production new file mode 100644 index 0000000..5d87d68 --- /dev/null +++ b/.env.production @@ -0,0 +1,2 @@ +GATSBY_WEBSITE_VERSION="1.0.0" +ASSET_PREFIX="https://cdn.decentraland.org/@dcl/art-week-site/1.0.0" diff --git a/.github/workflows/audit.yml b/.github/workflows/audit.yml new file mode 100644 index 0000000..9f71696 --- /dev/null +++ b/.github/workflows/audit.yml @@ -0,0 +1,18 @@ +name: Audit + +on: [push, pull_request] + +jobs: + audit: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + - name: Use Node.js 16.x + uses: actions/setup-node@v4.0.1 + with: + node-version: 16.x + cache: "npm" + - name: Install + run: npm i + - name: Audit signatures + run: npm audit signatures diff --git a/.github/workflows/build-release.yaml b/.github/workflows/build-release.yaml new file mode 100644 index 0000000..045fcae --- /dev/null +++ b/.github/workflows/build-release.yaml @@ -0,0 +1,45 @@ +name: Build and release + +on: + push: + branches: + - master + release: + types: + - created + +jobs: + build-release: + permissions: + id-token: write + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + - name: Use Node.js 16.x + uses: actions/setup-node@v4.0.1 + with: + node-version: 16.x + cache: "npm" + - name: Set package.json version + uses: menduz/oddish-action@master + with: + cwd: ./webapp + deterministic-snapshot: true + only-update-versions: true + - name: Install + run: npm install + - name: Build + env: + NODE_ENV: production + run: npm run build -- --prefix-paths + - name: Publish + uses: menduz/oddish-action@master + with: + cwd: ./public + deterministic-snapshot: true + registry-url: "https://registry.npmjs.org" + access: public + gitlab-token: ${{ secrets.GITLAB_CDN_DEPLOYER_TOKEN }} + gitlab-pipeline-url: ${{ secrets.GITLAB_CDN_DEPLOYER_URL }} + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 49515eb..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,37 +0,0 @@ -name: release - -on: - push: - branches: - - master - -jobs: - - release: - runs-on: ubuntu-20.04 - - steps: - - uses: actions/checkout@v2 - - - name: node.js 12 - uses: actions/setup-node@v2 - with: - node-version: 14 - cache: 'npm' - - - name: installing - run: npm ci - - - name: building - run: npm run build - env: - CI: true - - # publish to gh pages - - name: publishing documents - uses: peaceiris/actions-gh-pages@v3 - with: - DEPLOY_KEY: ${{ secrets.DEPLOY_KEY }} - PUBLISH_BRANCH: gh-pages - PUBLISH_DIR: ./public - CNAME: themetaversefestival.io \ No newline at end of file diff --git a/.github/workflows/set-rollout-manual.yaml b/.github/workflows/set-rollout-manual.yaml new file mode 100644 index 0000000..593afbf --- /dev/null +++ b/.github/workflows/set-rollout-manual.yaml @@ -0,0 +1,46 @@ +name: Set rollout by path - Manual + +on: + workflow_dispatch: + inputs: + packageVersion: + description: "NPM Version of the release (@dcl/art-week-site)" + required: true + default: "" + deploymentEnvironment: + type: "choice" + description: "Deployment environment" + required: true + default: "zone" + options: + - zone + - today + - org + rolloutPercentage: + description: "The percentage for this rollout" + required: true + default: "100" + +jobs: + set-manual-by-path-rollout: + runs-on: ubuntu-latest + steps: + - uses: hmarr/debug-action@v2 + - name: Set Rollout + uses: decentraland/set-rollout-action@v2 + with: + token: ${{ secrets.GITHUB_TOKEN }} + + # Repo deployment info + ref: ${{ github.event.ref }} + sha: ${{ github.sha }} + + # CDN information + packageName: "@dcl/art-week-site" + packageVersion: ${{ github.event.inputs.packageVersion }} + + # Rollout information + deploymentPath: "artweek" + deploymentEnvironment: ${{ github.event.inputs.deploymentEnvironment }} + deploymentName: "_site" + percentage: ${{ github.event.inputs.rolloutPercentage }} diff --git a/.github/workflows/set-rollout.yaml b/.github/workflows/set-rollout.yaml new file mode 100644 index 0000000..a4176b9 --- /dev/null +++ b/.github/workflows/set-rollout.yaml @@ -0,0 +1,50 @@ +name: Set rollout by path + +on: [deployment_status] + +jobs: + set-rollout: + if: ${{ github.event.deployment.task == 'upload-to-cdn' && github.event.deployment_status.state == 'success' }} + runs-on: ubuntu-latest + steps: + - uses: hmarr/debug-action@v2 + + # Dev + - name: Set Rollout - Development + uses: decentraland/set-rollout-action@v2 + with: + token: ${{ secrets.GITHUB_TOKEN }} + + # Repo deployment info + ref: ${{ github.event.deployment.ref }} + sha: ${{ github.event.deployment.sha }} + + # CDN information + packageName: ${{ github.event.deployment.payload.packageName }} + packageVersion: ${{ github.event.deployment.payload.packageVersion }} + + # Rollout information + deploymentPath: "artweek" + deploymentEnvironment: "zone" + deploymentName: "_site" + percentage: 100 + + # Stg + - name: Set Rollout - Staging + uses: decentraland/set-rollout-action@v2 + with: + token: ${{ secrets.GITHUB_TOKEN }} + + # Repo deployment info + ref: ${{ github.event.deployment.ref }} + sha: ${{ github.event.deployment.sha }} + + # CDN information + packageName: ${{ github.event.deployment.payload.packageName }} + packageVersion: ${{ github.event.deployment.payload.packageVersion }} + + # Rollout information + deploymentPath: "artweek" + deploymentEnvironment: "today" + deploymentName: "_site" + percentage: 100 diff --git a/.gitignore b/.gitignore index 238060b..1902588 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,6 @@ public .cache .DS_Store yarn.lock -package.lock \ No newline at end of file +package.lock +.env.production +package.json.tmp \ No newline at end of file diff --git a/README.md b/README.md index 00eb8b0..6231fe5 100644 --- a/README.md +++ b/README.md @@ -1,3 +1 @@ -# DCLMF 2023 - Decentraland Music Festival - -![festival](./static/logo-metaverse.png) +# DCL Art Week Site - Decentraland Art Week diff --git a/gatsby-config.js b/gatsby-config.js index 6c93260..a39db75 100644 --- a/gatsby-config.js +++ b/gatsby-config.js @@ -1,8 +1,13 @@ +require("dotenv").config({ + path: `.env.${process.env.NODE_ENV}`, +}); + module.exports = { siteMetadata: { - siteUrl: "https://www.yourdomain.tld", - title: "metaverse-festival", + siteUrl: "https://decentraland.org/artweek", + title: "Decentraland Art Week", }, + assetPrefix: process.env.ASSET_PREFIX, plugins: [ "gatsby-plugin-styled-components", "gatsby-plugin-image", @@ -26,18 +31,18 @@ module.exports = { GitHub: `https://github.com/francisco-zx`, }, { - Designer: 'GM Studios', - LinkedIn: 'https://github.com/gmstudiosgg' - } + Designer: "GM Studios", + LinkedIn: "https://github.com/gmstudiosgg", + }, ], site: { - 'Last update': `2022/10/08`, + "Last update": `2022/10/08`, Standards: `JavaScript`, Components: `humans-generator`, - Softwares: `Visual Studio Code, Mac OSX, Adobe Illustrator` + Softwares: `Visual Studio Code, Mac OSX, Adobe Illustrator`, }, - note: `Made in Buenos Aires, Argentina.` - } - } + note: `Made in Buenos Aires, Argentina.`, + }, + }, ], }; diff --git a/package-lock.json b/package-lock.json index dce6885..cbd2a39 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,11 +1,11 @@ { - "name": "metaverse-festival", + "name": "@dcl/art-week", "version": "1.0.0", "lockfileVersion": 2, "requires": true, "packages": { "": { - "name": "metaverse-festival", + "name": "@dcl/art-week", "version": "1.0.0", "dependencies": { "babel-plugin-styled-components": "^1.13.2", @@ -27,6 +27,9 @@ "react-multi-carousel": "^2.8.2", "react-player": "^2.9.0", "styled-components": "^5.3.1" + }, + "engines": { + "node": "18" } }, "node_modules/@ardatan/aggregate-error": { diff --git a/package.json b/package.json index 9cc0174..3fa09d2 100644 --- a/package.json +++ b/package.json @@ -1,13 +1,15 @@ { - "name": "metaverse-festival", + "name": "@dcl/art-week-site", "version": "1.0.0", "private": true, - "description": "metaverse-festival", - "author": "Guido La Rosa", + "description": "Art Week", + "author": "Decentraland", "keywords": [ "gatsby" ], "scripts": { + "prebuild": "node scripts/prebuild.js", + "postbuild": "node scripts/postbuild.js", "develop": "gatsby develop --https", "start": "gatsby develop --https", "build": "gatsby build", @@ -34,5 +36,13 @@ "react-multi-carousel": "^2.8.2", "react-player": "^2.9.0", "styled-components": "^5.3.1" + }, + "engines": { + "node": "16" + }, + "homepage": "https://decentraland.org", + "repository": { + "type": "git", + "url": "https://github.com/decentraland/artweek.git" } } diff --git a/scripts/postbuild.js b/scripts/postbuild.js new file mode 100644 index 0000000..430e6aa --- /dev/null +++ b/scripts/postbuild.js @@ -0,0 +1,7 @@ +const fs = require("fs"); + +const PACKAGE_JSON_PUBLIC_PATH = "./public/package.json"; +const PACKAGE_JSON_TEMP_PATH = "./package.json.tmp"; + +fs.copyFileSync(PACKAGE_JSON_TEMP_PATH, PACKAGE_JSON_PUBLIC_PATH); +fs.unlinkSync(PACKAGE_JSON_TEMP_PATH); diff --git a/scripts/prebuild.js b/scripts/prebuild.js new file mode 100644 index 0000000..c731cbf --- /dev/null +++ b/scripts/prebuild.js @@ -0,0 +1,62 @@ +/* eslint-disable */ +const fs = require("fs"); +const dotenv = require("dotenv"); + +dotenv.config(); + +let ENV_CONTENT = {}; + +// read files +if (fs.existsSync(".env")) { + Object.assign(ENV_CONTENT, dotenv.parse(fs.readFileSync(".env"))); +} +const packageJson = JSON.parse(fs.readFileSync("./package.json").toString()); + +// set version +ENV_CONTENT["GATSBY_WEBSITE_VERSION"] = packageJson.version; + +// set public url +Object.assign(ENV_CONTENT, getPublicUrls()); +packageJson.homepage = ENV_CONTENT["ASSET_PREFIX"]; +if (packageJson.homepage) { + // github action outputs. Do not touch. + console.log("::set-output name=public_url::" + packageJson.homepage); + console.log( + "::set-output name=public_path::" + new URL(packageJson.homepage).pathname + ); +} + +// log stuff +console.log("VERSIONS: ", Object.entries(ENV_CONTENT), "\n"); + +// save files +fs.writeFileSync( + ".env.production", + Object.entries(ENV_CONTENT) + .map((e) => e[0] + "=" + JSON.stringify(e[1])) + .join("\n") + "\n" +); +fs.writeFileSync("./package.json.tmp", JSON.stringify(packageJson, null, 2)); + +// public url logic +function getPublicUrls() { + const isStatic = !!process.env.GEN_STATIC_LOCAL; + const isCI = !!process.env.CI; + const isCDN = !isStatic && isCI; + console.log("is static", isStatic); + console.log("is CI", isCI); + console.log("is CDN", isCDN); + if (isCDN) { + // master/main branch, also releases + const cdnUrl = `https://cdn.decentraland.org/${packageJson.name}/${packageJson.version}`; + console.log(`Using CDN as public url: "${cdnUrl}"`); + return { + ASSET_PREFIX: cdnUrl, + }; + } + // localhost + console.log("Using empty pubic url"); + return { + ASSET_PREFIX: "", + }; +}