refactor: use fasyslog for creating syslog payload #3668
Workflow file for this run
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
name: Call Build Preview | |
on: | |
pull_request: | |
types: [opened, reopened, synchronize] | |
jobs: | |
approval_check: | |
runs-on: ubuntu-24.04 | |
timeout-minutes: 5 | |
# Only run for PRs with 'website' in the branch name | |
if: ${{ contains(github.head_ref, 'website') }} | |
steps: | |
- name: Echo approval | |
run: | | |
echo "Workflow has been allowed to run for PR ${{ github.event.number }}. Setting artifacts and then continuing workflow runs" | |
# Use GitHub Action to safely validate and store PR information | |
- name: Validate and save PR information | |
uses: actions/github-script@v7.0.1 | |
with: | |
script: | | |
const fs = require('fs').promises; | |
const path = require('path'); | |
const crypto = require('crypto'); | |
async function createAndValidateArtifact() { | |
try { | |
// Create directory for artifact | |
await fs.mkdir('./pr', { recursive: true }); | |
// Get PR number and validate | |
const prNumber = context.payload.number; | |
if (typeof prNumber !== 'number' || !Number.isInteger(prNumber) || prNumber <= 0) { | |
core.setFailed(`Invalid PR number: ${prNumber}`); | |
return; | |
} | |
// Get branch name and validate | |
const branchName = context.payload.pull_request.head.ref; | |
// Validate branch name (only allow alphanumeric, dash, and underscore) | |
const branchNameRegex = /^[a-zA-Z0-9_\-]+$/; | |
if (!branchNameRegex.test(branchName)) { | |
core.setFailed(`Invalid branch name detected: ${branchName}`); | |
return; | |
} | |
// Write validated information to files | |
await fs.writeFile('./pr/number', prNumber.toString()); | |
await fs.writeFile('./pr/branch', branchName); | |
// Log success | |
core.info(`Successfully validated and saved PR #${prNumber} with branch ${branchName}`); | |
// Create hash signature of the data | |
const numberHash = crypto.createHash('sha256').update(prNumber.toString()).digest('hex'); | |
const branchHash = crypto.createHash('sha256').update(branchName).digest('hex'); | |
await fs.writeFile('./pr/integrity', `${numberHash}:${branchHash}`); | |
} catch (error) { | |
core.setFailed(`An error occurred: ${error.message}`); | |
} | |
} | |
createAndValidateArtifact(); | |
# Upload the artifact using latest version | |
- name: Upload PR information artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: pr | |
path: pr/ | |
retention-days: 1 |