Fetch Etherscan Logs and CodeQL Analysis #496
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: Fetch Etherscan Logs and CodeQL Analysis | ||
on: | ||
schedule: | ||
- cron: "0 */2 * * *" # Runs every 2 hours for fetching logs | ||
- cron: '0 0 * * *' # Runs daily for CodeQL analysis | ||
workflow_dispatch: # Allows manual triggers | ||
pull_request: | ||
branches: | ||
- main # Allows Dependabot to trigger the workflow | ||
jobs: | ||
fetch-etherscan-logs: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
- name: Set up Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: '16' | ||
- name: Fetch logs from Etherscan API and create random JSON files | ||
env: | ||
ETHERSCAN_API: ${{ secrets.ETHERSCAN_API }} | ||
run: | | ||
mkdir -p FlashTetherUSDT/transaction/api/data | ||
response=$(curl -s "https://api.etherscan.io/api?module=logs&action=getLogs&address=0xbd3531da5cf5857e7cfaa92426877b022e612cf8&fromBlock=12878196&toBlock=12878196&page=1&offset=1000&apikey=$ETHERSCAN_API") | ||
status=$(echo "$response" | jq -r '.status') | ||
message=$(echo "$response" | jq -r '.message') | ||
if [ "$status" = "1" ] && [ "$message" = "OK" ]; then | ||
echo "$response" | jq -c '.result[]' | shuf -n 10 | while read log_entry; do | ||
address=$(echo "$log_entry" | jq -r '.address') | ||
transaction_hash=$(echo "$log_entry" | jq -r '.transactionHash') | ||
file_name="FlashTetherUSDT/transaction/api/data/${address}_${transaction_hash}.json" | ||
echo "$log_entry" > "$file_name" | ||
done | ||
else | ||
echo "API response invalid: $message" | ||
exit 1 | ||
fi | ||
- name: Commit and push the JSON files | ||
env: | ||
GITPAT: ${{ secrets.GITPAT }} | ||
run: | | ||
git config --local user.email "likhonexe@gmail.com" | ||
git config --local user.name "@nectariferous" | ||
git add FlashTetherUSDT/transaction/api/data/ | ||
git commit -m "Add 10 random Etherscan API logs for $(date +"%Y-%m-%d %H:%M:%S")" | ||
git push https://$GITPAT@github.com/${{ github.repository }}.git HEAD:main | ||
codeql-analysis: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
- name: Initialize CodeQL | ||
uses: github/codeql-action/init@v2 | ||
with: | ||
languages: ['javascript', 'python'] | ||
Check failure on line 59 in .github/workflows/npm-publish-github-packages.yml GitHub Actions / Fetch Etherscan Logs and CodeQL AnalysisInvalid workflow file
|
||
- name: Autobuild | ||
uses: github/codeql-action/autobuild@v2 | ||
- name: Perform CodeQL Analysis | ||
uses: github/codeql-action/analyze@v2 |