Skip to content

Commit

Permalink
Production Deploy (#13913)
Browse files Browse the repository at this point in the history
* Manual deploy as of commit:066be2cfa226a71403c6ed592425c911a032eb78

* fix(unlock-app): fixing the broken login flows (#13914)

* Revert "fix(unlock-account): Checkout email waiting fix (#13906)"

This reverts commit 5511627.

* some simplification and refactoring for our login flows

* Updated autoSignIn flow

* Update Connected.tsx

---------

Co-authored-by: Viacheslav <surzhenkoviacheslav@gmail.com>

---------

Co-authored-by: Viacheslav <surzhenkoviacheslav@gmail.com>
  • Loading branch information
julien51 and SVell committed May 31, 2024
1 parent da895be commit 8570fbe
Show file tree
Hide file tree
Showing 166 changed files with 6,671 additions and 8,098 deletions.
3 changes: 2 additions & 1 deletion .clabot
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"contributors": [
"NikhilMahana",
"xdamman",
"unlock-deployer",
"smombartz",
Expand Down Expand Up @@ -69,4 +70,4 @@
"Tguntenaar"
],
"message": "Thank you for your pull request and welcome to Unlock! We require contributors to sign our [Contributor License Agreement](https://github.com/unlock-protocol/unlock/blob/master/CLA.txt), and we don't seem to have the users {{usersWithoutCLA}} on file. \nIn order for us to review and merge your code, please open _another_ pull request with a single modification: your github username added to the file `.clabot`.\nThank you! "
}
}
30 changes: 2 additions & 28 deletions .github/actions/blog/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,9 @@ name: Fetch and Create Blog Posts
description: Fetches the latest blog posts from the Unlock Protocol blog and creates new posts in the website repository.
on:
schedule:
- cron: '0 0 * * *' # Run once per day at midnight
- cron: '0 0 * * *' # Run once per day at midnight
pull_request:

jobs:
fetch_and_create_posts:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install feedparser requests
- name: Fetch RSS feed and create posts
run: python rss_feed.py

- name: Create Pull Request
uses: peter-evans/create-pull-request@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "Add new blog posts"
title: "New blog posts from RSS feed"
body: "Automatically generated PR to add new blog posts fetched from the RSS feed."
branch: new-blog-posts
uses: ./.github/workflows/import-blog
36 changes: 36 additions & 0 deletions .github/actions/blog/mock_rss_feed.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title>Sample Blog</title>
<link>https://example.com</link>
<description>This is a sample RSS feed for testing.</description>
<language>en-us</language>

<item>
<title>First Blog Post</title>
<link>https://example.com/first-blog-post</link>
<pubDate>Wed, 01 Apr 2023 12:00:00 GMT</pubDate>
<description>This is the summary of the first blog post.</description>
<author>Author One</author>
<content:encoded
><![CDATA[<p>This is the <strong>content</strong> of the first blog post.</p>]]></content:encoded>
<image>
<href>https://example.com/images/first.jpg</href>
</image>
</item>

<item>
<title>Second Blog Post</title>
<link>https://example.com/second-blog-post</link>
<pubDate>Thu, 02 Apr 2023 12:00:00 GMT</pubDate>
<description>This is the summary of the second blog post.</description>
<author>Author Two</author>
<content:encoded
><![CDATA[<p>This is the <strong>content</strong> of the second blog post.</p>]]></content:encoded>
<image>
<href>https://example.com/images/second.jpg</href>
</image>
</item>

</channel>
</rss>
133 changes: 133 additions & 0 deletions .github/actions/blog/rss_feed.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
const fs = require('fs-extra')
const path = require('path')
const fetch = require('node-fetch')
const feedparser = require('feedparser-promised')

// Fetch the RSS feed
const rssUrl = 'https://paragraph.xyz/api/blogs/rss/@unlockprotocol'
//const rssUrl = 'https://gist.githubusercontent.com/njokuScript/49c95765a21de9a7cf01c72f06149769/raw/5f62f27fc2a9c37e992d7834e86361a72cbfeeca/mock_rss_feed.xml'

// Create the base directory for storing blog posts
const blogDir = '../../../unlock-protocol-com/blog'
fs.ensureDirSync(blogDir)

// Load the titles of existing blog posts to check for duplicates
const existingTitles = new Set()
fs.readdirSync(blogDir).forEach((filename) => {
if (filename.endsWith('.md')) {
const content = fs.readFileSync(path.join(blogDir, filename), 'utf8')
const titleMatch = content.match(/^title: "(.*)"/m)
if (titleMatch) {
existingTitles.add(titleMatch[1])
}
}
})

const downloadImage = (url, filepath) => {
return fetch(url)
.then((res) => res.buffer())
.then((buffer) => fs.writeFile(filepath, buffer))
.catch((error) => console.error(`Error downloading image ${url}:`, error))
}

const extractAndDownloadImages = (content, postImagesDir, slug) => {
const imageRegex = /<img[^>]+src="([^">]+)"/g
let updatedContent = content
let match
const imagePromises = []

while ((match = imageRegex.exec(content)) !== null) {
const imageUrl = match[1]
const imageFilename = path.basename(imageUrl)
const localImagePath = path.join(postImagesDir, imageFilename)
// Extract and download images from the content and update the content with local image paths
const imagePromise = downloadImage(imageUrl, localImagePath).then(() => {
updatedContent = updatedContent.replace(
imageUrl,
`/images/blog/${slug}/${imageFilename}`
)
})
imagePromises.push(imagePromise)
}

return Promise.all(imagePromises).then(() => updatedContent)
}
// Iterate over each post in the feed
feedparser
.parse(rssUrl)
.then((entries) => {
entries.forEach((entry, count) => {
const title = entry.title
const subtitle = entry.subtitle || ''
const authorName = entry.author || 'Unlock Labs team'
const publishDate = entry.pubDate
const description = entry.summary
let imageUrl = entry.image && entry.image.href ? entry.image.href : ''

if (!imageUrl) {
const enclosuresImage = entry.enclosures.find((enclosure) => {
return enclosure.type.startsWith('image')

})
if (enclosuresImage) {
imageUrl = enclosuresImage.url
}
}

// Skip if the title already exists
if (existingTitles.has(title)) {
return
}
// Generate a slug for the blog post
const slug = title
.replace(/[^\w\-_\. ]/g, '-')
.toLowerCase()
.replace(/ /g, '-')
const postImagesDir = path.join(
'../../../unlock-protocol-com/public/images/blog',
slug
)
fs.ensureDirSync(postImagesDir)
// Download the featured image and save it locally
let imageDownloadPromise = Promise.resolve()
if (imageUrl) {
const imageFilename = path.basename(imageUrl)
const localImagePath = path.join(postImagesDir, imageFilename)
imageDownloadPromise = downloadImage(imageUrl, localImagePath)
}

// Create the post content with the updated content
imageDownloadPromise
.then(() => {
return extractAndDownloadImages(
entry.description,
postImagesDir,
slug
)
})
.then((updatedContent) => {
const postContent = `---
title: "${title}"
subtitle: "${subtitle}"
authorName: "${authorName}"
publishDate: "${publishDate}"
description: "${description}"
image: "/images/blog/${slug}/${path.basename(
imageUrl
)}"
---
![${title}](${imageUrl})
${updatedContent}`

const postFilename = `${slug}.md`
const postFilePath = path.join(blogDir, postFilename)
fs.writeFileSync(postFilePath, postContent)
existingTitles.add(title)
})
})
})
.catch((error) => {
console.error('Error fetching RSS feed:', error)
})
60 changes: 0 additions & 60 deletions .github/actions/blog/rss_feed.py

This file was deleted.

33 changes: 33 additions & 0 deletions .github/workflows/import-blog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Fetch and Create Blog Posts
on:
schedule:
- cron: '0 0 * * *' # Run once per day at midnight
workflow_dispatch:

jobs:
fetch_and_create_posts:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Install dependencies
run: npm install

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '20'

- name: Run RSS Feed Script
run: node rss_feed.js

- name: Create Pull Request
uses: peter-evans/create-pull-request@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: 'Add new blog posts'
title: 'New blog posts from RSS feed'
body: 'Automatically generated PR to add new blog posts fetched from the RSS feed.'
branch: new-blog-posts
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ yarn-error.log
# Local Netlify folder
.netlify
.vercel
governance/.openzeppelin/unknown-31337.json

# log files
nohup.out
1 change: 1 addition & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,4 @@ This Code of Conduct is adapted from the [Contributor Covenant][homepage], versi
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html

[homepage]: https://www.contributor-covenant.org

Loading

0 comments on commit 8570fbe

Please sign in to comment.