-
Notifications
You must be signed in to change notification settings - Fork 220
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: fixing versioning workflow (#3296)
- Loading branch information
1 parent
f9933fa
commit 3d5e43a
Showing
20 changed files
with
120 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,12 +2,6 @@ name: Build docs | |
|
||
on: | ||
pull_request: | ||
paths: | ||
- 'docs/**' | ||
types: | ||
- opened | ||
- synchronize | ||
- labeled | ||
|
||
jobs: | ||
add_label: | ||
|
@@ -53,7 +47,7 @@ jobs: | |
}) | ||
} | ||
deploy_docs: | ||
build_and_deploy: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
pull-requests: write | ||
|
@@ -62,81 +56,32 @@ jobs: | |
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Netlify deploy | ||
run: | | ||
BRANCH_NAME=$(echo "${{ github.head_ref || github.ref }}" | sed -e "s#refs/[^/]*/##") | ||
curl -X POST -d {} "https://api.netlify.com/build_hooks/${{ secrets.NETLIFY_BUILD_HOOK }}?trigger_branch=$BRANCH_NAME" | ||
- name: Get deploy preview | ||
id: get_deploy_preview | ||
run: | | ||
BRANCH_NAME=$(echo "${{ github.head_ref || github.ref }}" | sed -e "s#refs/[^/]*/##") | ||
curl -X GET "https://api.netlify.com/api/v1/sites/${{ secrets.NETLIFY_SITE_ID }}/deploys?branch=$BRANCH_NAME" > deploy.json | ||
echo "::set-output name=deploy_url::$(cat deploy.json | jq -r '.[0].deploy_ssl_url')" | ||
- name: Add PR Comment | ||
uses: mshick/add-pr-comment@v2 | ||
with: | ||
message: | | ||
Hey @${{ github.event.pull_request.user.login }}! 🙌 | ||
I'm the deployment bot for Noir Docs, and I've got some updates for you: | ||
## Deployment Status | ||
Your latest changes are being deployed for preview! 🚀 | ||
Click the badge to see logs 🧐 | ||
[![Netlify Status](https://api.netlify.com/api/v1/badges/${{ secrets.NETLIFY_SITE_ID }}/deploy-status?branch=${{ github.head_ref || github.ref }})](https://app.netlify.com/sites/noir-docs-v2/deploys) | ||
If you have any questions about this process, refer to our contribution guide or feel free to ask around. | ||
- name: Check on deploy status | ||
uses: ./.github/actions/docs/build-status | ||
id: check_deploy_status | ||
with: | ||
branch-name: ${{ github.head_ref || github.ref }} | ||
site-id: ${{ secrets.NETLIFY_SITE_ID }} | ||
continue-on-error: true | ||
|
||
|
||
- name: Debugging - print deploy_status | ||
run: echo "${{ steps.check_deploy_status.outputs.deploy_status }}" | ||
|
||
|
||
- name: Change PR Comment for Successful Deployment | ||
if: steps.check_deploy_status.outputs.deploy_status == 'success' | ||
uses: mshick/add-pr-comment@v2 | ||
|
||
- name: Setup Node.js | ||
uses: actions/setup-node@v2 | ||
with: | ||
message-success: | | ||
![It's Alive!](https://i.imgflip.com/82hw5n.jpg) | ||
I'm a bot, beep boop 🤖 | ||
## Deployment Status: Success! | ||
[![Netlify Status](https://api.netlify.com/api/v1/badges/${{ secrets.NETLIFY_SITE_ID }}/deploy-status?branch=${{ github.head_ref || github.ref }})](https://app.netlify.com/sites/noir-docs-v2/deploys) | ||
## Preview | ||
🌐 [View Deployment Preview](${{ steps.get_deploy_preview.outputs.deploy_url }}) | ||
node-version: '18' | ||
|
||
- name: Change PR Comment for Failed Deployment | ||
if: steps.check_deploy_status.outputs.deploy_status == 'failure' | ||
uses: mshick/add-pr-comment@v2 | ||
- name: Install dependencies | ||
run: yarn | ||
|
||
- name: Build docs | ||
run: yarn workspace docs build | ||
|
||
- name: Remove pre-releases | ||
working-directory: docs | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: yarn setStable | ||
|
||
- name: Deploy to Netlify | ||
uses: nwtgck/[email protected] | ||
with: | ||
message: | | ||
![docs CI troll](https://i.imgflip.com/82ht8f.jpg) | ||
I'm a bot, beep boop 🤖 | ||
## Deployment Status: Failed ❌ | ||
Deployment didn't succeed. Please check logs below and resolve the issue 🧐 | ||
[![Netlify Status](https://api.netlify.com/api/v1/badges/${{ secrets.NETLIFY_SITE_ID }}/deploy-status?branch=${{ github.head_ref || github.ref }})](https://app.netlify.com/sites/noir-docs-v2/deploys) | ||
- name: Fail the workflow if deployment failed | ||
if: steps.check_deploy_status.outputs.deploy_status == 'failure' | ||
run: exit 1 | ||
publish-dir: './docs/build' | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
enable-github-deployment: false | ||
deploy-message: "Deploy from GitHub Actions for PR ${{ github.event.number }}" | ||
env: | ||
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} | ||
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} | ||
timeout-minutes: 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,4 +20,4 @@ npm-debug.log* | |
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
package-lock.json | ||
package-lock.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* eslint-disable */ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const axios = require('axios'); | ||
const { release } = require('os'); | ||
|
||
const IGNORE_VERSIONS = ['0.16.0']; | ||
const NUMBER_OF_VERSIONS_TO_SHOW = 2; | ||
|
||
async function main() { | ||
const versionsFile = path.join(__dirname, '../versions.json'); | ||
|
||
const axiosOpts = { | ||
params: { per_page: 100 }, | ||
}; | ||
|
||
console.log(process.env.GITHUB_TOKEN); | ||
// cool if you have a GITHUB_TOKEN because of rate limiting | ||
// but fine if you don't | ||
if (process.env.GITHUB_TOKEN) axiosOpts.headers = { Authorization: `token ${process.env.GITHUB_TOKEN}` }; | ||
|
||
const { data } = await axios.get('https://api.github.com/repos/noir-lang/noir/releases', axiosOpts); | ||
|
||
const all = data.map((release) => release.tag_name); | ||
console.log('All versions: ', all); | ||
const aztecs = data.filter((release) => release.tag_name.includes('aztec')).map((release) => release.tag_name); | ||
console.log('Removing aztecs: ', aztecs); | ||
const prereleases = data.filter((release) => !release.prerelease).map((release) => release.tag_name); | ||
console.log('Removing prereleases: ', prereleases); | ||
|
||
const stables = data | ||
.filter((release) => !release.prerelease && !release.tag_name.includes('aztec')) | ||
.filter((release) => !IGNORE_VERSIONS.includes(release.tag_name.replace('v', ''))) | ||
.map((release) => release.tag_name.replace('v', '')) | ||
.slice(0, NUMBER_OF_VERSIONS_TO_SHOW); | ||
|
||
console.log('Stables: ', stables); | ||
fs.writeFileSync(versionsFile, JSON.stringify(stables, null, 2)); | ||
} | ||
|
||
main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.