-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1209 from tubone24/fix_ad
Fix ad
- Loading branch information
Showing
7 changed files
with
129 additions
and
9 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 |
---|---|---|
|
@@ -6,3 +6,4 @@ functions/src/complaints* | |
storybook-static/* | ||
static/adstir.js | ||
coverage/* | ||
scripts/uploadScreenShot.ts |
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 |
---|---|---|
|
@@ -297,3 +297,38 @@ jobs: | |
publish_dir: ./public | ||
destination_dir: lh | ||
keep_files: true | ||
|
||
webscreenshot: | ||
needs: | ||
- build | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest] | ||
width: [1920, 1200, 768, 400] | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: denoland/setup-deno@v1 | ||
with: | ||
deno-version: 'v1.x' | ||
- name: install noto font | ||
run: sudo apt install fonts-noto | ||
- name: Capture Webpage Screenshot | ||
uses: swinton/[email protected] | ||
with: | ||
source: "https://blog.tubone-project24.xyz" | ||
destination: screenshot-${{ matrix.os }}-${{ matrix.width }}.png | ||
width: ${{ matrix.width }} | ||
delay: 10 | ||
- uses: actions/download-artifact@v3 | ||
with: | ||
name: screenshot-${{ matrix.os }}-${{ matrix.width }} | ||
- name: PR Comments | ||
env: | ||
FILE_PATH: screenshot-${{ matrix.os }}-${{ matrix.width }}.png | ||
FILE_NAME: screenshot-${{ matrix.os }}-${{ matrix.width }}.png | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
GITHUB_REPOSITORY: "tubone24/blog" | ||
GITHUB_PULL_REQUEST_NUMBER: ${{ steps.get-pr-num.outputs.prnum }} | ||
BRANCH_NAME: "master" | ||
run: deno run --allow-env --allow-read --allow-net scripts/uploadScreenShot.ts |
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 |
---|---|---|
|
@@ -487,26 +487,45 @@ jobs: | |
run: | ||
gh pr comment -F ./comments.txt "${URL}" | ||
|
||
|
||
webscreenshot: | ||
needs: | ||
- build | ||
- check-skip-flags | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest] | ||
width: [1200, 992, 768, 600] | ||
width: [1920, 1200, 768, 400] | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: denoland/setup-deno@v1 | ||
with: | ||
deno-version: 'v1.x' | ||
- name: install noto font | ||
run: sudo apt install fonts-noto | ||
- name: Capture Webpage Screenshot | ||
if: ${{ !contains(needs.check-skip-flags.outputs.head-commit-message, '[skip netlify]') }} | ||
uses: swinton/[email protected].0 | ||
uses: swinton/[email protected].2 | ||
with: | ||
source: ${{ needs.build.outputs.draftUrl }} | ||
destination: screenshot-${{ matrix.os }}-${{ matrix.width }}.png | ||
width: ${{ matrix.width }} | ||
- uses: actions/upload-artifact@v3 | ||
delay: 10 | ||
- uses: actions/download-artifact@v3 | ||
with: | ||
name: screenshot-${{ matrix.os }}-${{ matrix.width }}.png | ||
path: screenshot-${{ matrix.os }}-${{ matrix.width }}.png | ||
name: screenshot-${{ matrix.os }}-${{ matrix.width }} | ||
- name: ls | ||
run: ls -la | ||
- name: Get PR Number | ||
id: get-pr-num | ||
run: echo "prnum=$(echo $GITHUB_REF | sed -e 's/[^0-9]//g')" >> $GITHUB_OUTPUT | ||
- name: PR Comments | ||
env: | ||
FILE_PATH: screenshot-${{ matrix.os }}-${{ matrix.width }}.png | ||
FILE_NAME: screenshot-${{ matrix.os }}-${{ steps.get-pr-num.outputs.prnum }}-${{ github.head_ref }}-${{ matrix.width }}.png | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
GITHUB_REPOSITORY: "tubone24/blog" | ||
GITHUB_PULL_REQUEST_NUMBER: ${{ steps.get-pr-num.outputs.prnum }} | ||
BRANCH_NAME: "screenshot" | ||
run: deno run --allow-env --allow-read --allow-net scripts/uploadScreenShot.ts | ||
|
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 |
---|---|---|
|
@@ -45,4 +45,4 @@ test/memlab/data | |
# OWASPZAP | ||
owasp/zap/*.key | ||
owasp/zap/*.cer | ||
owasp/zap/zapHome/ | ||
owasp/zap/zapHome/ |
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,43 @@ | ||
import { encode } from "https://deno.land/std/encoding/base64.ts"; | ||
|
||
const GITHUB_API_URL = "https://api.github.com"; | ||
const AUTHOR_NAME = "github-actions[bot]"; | ||
const AUTHOR_EMAIL = "github-actions[bot]@users.noreply.github.com"; | ||
const filePath = Deno.env.get("FILE_PATH") as string; | ||
const fileName = Deno.env.get("FILE_NAME") as string; | ||
const gitHubToken = Deno.env.get("GITHUB_TOKEN") as string; | ||
const gitHubRepo = Deno.env.get("GITHUB_REPOSITORY") as string; | ||
const prNumber = Deno.env.get("GITHUB_PULL_REQUEST_NUMBER") as string; | ||
const branchName = Deno.env.get("BRANCH_NAME") as string; | ||
|
||
const readImageData = await Deno.readFile(filePath); | ||
const encodedData = encode(readImageData); | ||
|
||
const gitHubPayload = { | ||
message: `[file upload] Added file for PR #${prNumber}`, | ||
content: encodedData.replace(new RegExp("data.*base64,"), ""), | ||
branch: branchName, | ||
author: { | ||
name: AUTHOR_NAME, | ||
email: AUTHOR_EMAIL, | ||
}, | ||
committer: { | ||
name: AUTHOR_NAME, | ||
email: AUTHOR_EMAIL, | ||
}, | ||
}; | ||
|
||
const gitHubHeaders = { | ||
Accept: "application/vnd.github.v3+json", | ||
Authorization: `Bearer ${gitHubToken}`, | ||
}; | ||
|
||
const gitHubUploadurl = `${GITHUB_API_URL}/repos/${gitHubRepo}/contents/docs/screenshot/${fileName}`; | ||
|
||
const gitHubRes = await fetch(gitHubUploadurl, { | ||
method: "PUT", | ||
headers: gitHubHeaders, | ||
body: JSON.stringify(gitHubPayload), | ||
}); | ||
|
||
console.log(gitHubRes); |