Merge pull request #476 from vogler/mega-linter
This commit is contained in:
commit
c5f061c7d5
15 changed files with 412 additions and 127 deletions
20
.cspell.json
Normal file
20
.cspell.json
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
{
|
||||||
|
"ignorePaths": [
|
||||||
|
"**/data/**",
|
||||||
|
"docker.yml",
|
||||||
|
"Dockerfile",
|
||||||
|
".jscpd.json",
|
||||||
|
"**/node_modules/**",
|
||||||
|
"**/vscode-extension/**",
|
||||||
|
"**/.git/**",
|
||||||
|
"**/.pnpm-lock.json",
|
||||||
|
".vscode",
|
||||||
|
"megalinter",
|
||||||
|
"package-lock.json",
|
||||||
|
"report"
|
||||||
|
],
|
||||||
|
"language": "en",
|
||||||
|
"noConfigSearch": true,
|
||||||
|
"words": ["megalinter", "oxsecurity", "ralf", "vogler", "DOCKERHUB"],
|
||||||
|
"version": "0.2"
|
||||||
|
}
|
||||||
4
.github/renovate.json
vendored
4
.github/renovate.json
vendored
|
|
@ -1,7 +1,5 @@
|
||||||
{
|
{
|
||||||
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
||||||
"enabled": false,
|
"enabled": false,
|
||||||
"extends": [
|
"extends": ["config:recommended"]
|
||||||
"config:recommended"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
30
.github/workflows/docker.yml
vendored
30
.github/workflows/docker.yml
vendored
|
|
@ -5,10 +5,10 @@ on:
|
||||||
push: # push on branch
|
push: # push on branch
|
||||||
branches: [main, dev]
|
branches: [main, dev]
|
||||||
paths: # ignore changes to .md files
|
paths: # ignore changes to .md files
|
||||||
- '**'
|
- "**"
|
||||||
- '!*.md'
|
- "!*.md"
|
||||||
# - '!.github/**'
|
# - '!.github/**'
|
||||||
pull_request: # runs when opened/reopned or when the head branch is updated
|
pull_request: # runs when opened/reopened or when the head branch is updated
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
|
|
@ -21,11 +21,9 @@ jobs:
|
||||||
docker:
|
docker:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
-
|
- name: Checkout
|
||||||
name: Checkout
|
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
-
|
- name: Set environment variables
|
||||||
name: Set environment variables
|
|
||||||
run: |
|
run: |
|
||||||
echo "NOW=$(date -R)" >> "$GITHUB_ENV" # date -Iseconds; date +'%Y-%m-%dT%H:%M:%S'
|
echo "NOW=$(date -R)" >> "$GITHUB_ENV" # date -Iseconds; date +'%Y-%m-%dT%H:%M:%S'
|
||||||
if [[ "$BRANCH" == "main" ]]; then
|
if [[ "$BRANCH" == "main" ]]; then
|
||||||
|
|
@ -33,8 +31,7 @@ jobs:
|
||||||
else
|
else
|
||||||
echo "IMAGE_TAG=$BRANCH" >> "$GITHUB_ENV"
|
echo "IMAGE_TAG=$BRANCH" >> "$GITHUB_ENV"
|
||||||
fi
|
fi
|
||||||
-
|
- name: Extract metadata for Docker (tags, labels)
|
||||||
name: Extract metadata for Docker (tags, labels)
|
|
||||||
id: meta
|
id: meta
|
||||||
uses: docker/metadata-action@v5
|
uses: docker/metadata-action@v5
|
||||||
with:
|
with:
|
||||||
|
|
@ -52,29 +49,24 @@ jobs:
|
||||||
# otherwise labels are not shown on GitHub due to multi-arch image: https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry#adding-a-description-to-multi-arch-images
|
# otherwise labels are not shown on GitHub due to multi-arch image: https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry#adding-a-description-to-multi-arch-images
|
||||||
# https://github.com/docker/metadata-action#annotations
|
# https://github.com/docker/metadata-action#annotations
|
||||||
DOCKER_METADATA_ANNOTATIONS_LEVELS: manifest,index
|
DOCKER_METADATA_ANNOTATIONS_LEVELS: manifest,index
|
||||||
-
|
- name: Login to Docker Hub
|
||||||
name: Login to Docker Hub
|
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
# if: ${{ secrets.DOCKERHUB_USERNAME != '' && secrets.DOCKERHUB_TOKEN != '' }} # does not work: Unrecognized named-value: 'secrets' - https://www.cloudtruth.com/blog/skipping-jobs-in-github-actions-when-secrets-are-unavailable-securely-inject-configuration-secrets-into-github
|
# if: ${{ secrets.DOCKERHUB_USERNAME != '' && secrets.DOCKERHUB_TOKEN != '' }} # does not work: Unrecognized named-value: 'secrets' - https://www.cloudtruth.com/blog/skipping-jobs-in-github-actions-when-secrets-are-unavailable-securely-inject-configuration-secrets-into-github
|
||||||
if: github.event_name != 'pull_request' # don't try to login since PRs don't have access to secrets and need to set them in their fork
|
if: github.event_name != 'pull_request' # don't try to login since PRs don't have access to secrets and need to set them in their fork
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
-
|
- name: Login to GitHub Container Registry
|
||||||
name: Login to GitHub Container Registry
|
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
registry: ghcr.io
|
registry: ghcr.io
|
||||||
username: ${{ github.actor }} # actor is user that opened PR, was repository_owner before
|
username: ${{ github.actor }} # actor is user that opened PR, was repository_owner before
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
-
|
- name: Set up QEMU
|
||||||
name: Set up QEMU
|
|
||||||
uses: docker/setup-qemu-action@v3
|
uses: docker/setup-qemu-action@v3
|
||||||
-
|
- name: Set up Docker Buildx
|
||||||
name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
-
|
- name: Build and push
|
||||||
name: Build and push
|
|
||||||
uses: docker/build-push-action@v6
|
uses: docker/build-push-action@v6
|
||||||
if: ${{ env.IMAGE_TAG != '' }}
|
if: ${{ env.IMAGE_TAG != '' }}
|
||||||
with:
|
with:
|
||||||
|
|
|
||||||
214
.github/workflows/mega-linter.yml
vendored
Normal file
214
.github/workflows/mega-linter.yml
vendored
Normal file
|
|
@ -0,0 +1,214 @@
|
||||||
|
# MegaLinter GitHub Action configuration file
|
||||||
|
# More info at https://megalinter.io
|
||||||
|
|
||||||
|
# See .mega-linter.yml for actual config and examples how to run this locally.
|
||||||
|
---
|
||||||
|
name: MegaLinter
|
||||||
|
|
||||||
|
# Trigger mega-linter at every push. Action will also be visible from
|
||||||
|
# Pull Requests to main
|
||||||
|
on:
|
||||||
|
# Comment this line to trigger action only on pull-requests
|
||||||
|
# (not recommended if you don't pay for GH Actions)
|
||||||
|
push:
|
||||||
|
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
- dev
|
||||||
|
|
||||||
|
# Comment env block if you do not want to apply fixes
|
||||||
|
env:
|
||||||
|
# Apply linter fixes configuration
|
||||||
|
#
|
||||||
|
# When active, APPLY_FIXES must also be defined as environment variable
|
||||||
|
# (in github/workflows/mega-linter.yml or other CI tool)
|
||||||
|
APPLY_FIXES: all
|
||||||
|
|
||||||
|
# Decide which event triggers application of fixes in a commit or a PR
|
||||||
|
# (pull_request, push, all)
|
||||||
|
APPLY_FIXES_EVENT: pull_request
|
||||||
|
|
||||||
|
# If APPLY_FIXES is used, defines if the fixes are directly committed (commit)
|
||||||
|
# or posted in a PR (pull_request)
|
||||||
|
APPLY_FIXES_MODE: commit
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.ref }}-${{ github.workflow }}
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
megalinter:
|
||||||
|
name: MegaLinter
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
# Give the default GITHUB_TOKEN write permission to commit and push, comment
|
||||||
|
# issues, and post new Pull Requests; remove the ones you do not need
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
issues: write
|
||||||
|
pull-requests: write
|
||||||
|
security-events: write # needed for SARIF upload
|
||||||
|
|
||||||
|
steps:
|
||||||
|
# Git Checkout
|
||||||
|
- name: Checkout Code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
# If you use VALIDATE_ALL_CODEBASE = true, you can remove this line to
|
||||||
|
# improve performance
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
# MegaLinter
|
||||||
|
- name: MegaLinter
|
||||||
|
|
||||||
|
# You can override MegaLinter flavor used to have faster performances
|
||||||
|
# More info at https://megalinter.io/latest/flavors/
|
||||||
|
# uses: oxsecurity/megalinter@v8 # default (127 linters)
|
||||||
|
uses: oxsecurity/megalinter/flavors/cupcake@v8.7.0 # most common, was recommended in output (88 linters)
|
||||||
|
|
||||||
|
id: ml
|
||||||
|
|
||||||
|
# All available variables are described in documentation
|
||||||
|
# https://megalinter.io/latest/config-file/
|
||||||
|
env:
|
||||||
|
# Validates all source when push on main, else just the git diff with
|
||||||
|
# main. Override with true if you always want to lint all sources
|
||||||
|
#
|
||||||
|
# To validate the entire codebase, set to:
|
||||||
|
# VALIDATE_ALL_CODEBASE: true
|
||||||
|
#
|
||||||
|
# To validate only diff with main, set to:
|
||||||
|
# VALIDATE_ALL_CODEBASE: >-
|
||||||
|
# ${{
|
||||||
|
# github.event_name == 'push' &&
|
||||||
|
# github.ref == 'refs/heads/main'
|
||||||
|
# }}
|
||||||
|
VALIDATE_ALL_CODEBASE: true
|
||||||
|
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
# Uncomment to use ApiReporter (Grafana)
|
||||||
|
# API_REPORTER: true
|
||||||
|
# API_REPORTER_URL: ${{ secrets.API_REPORTER_URL }}
|
||||||
|
# API_REPORTER_BASIC_AUTH_USERNAME: ${{ secrets.API_REPORTER_BASIC_AUTH_USERNAME }}
|
||||||
|
# API_REPORTER_BASIC_AUTH_PASSWORD: ${{ secrets.API_REPORTER_BASIC_AUTH_PASSWORD }}
|
||||||
|
# API_REPORTER_METRICS_URL: ${{ secrets.API_REPORTER_METRICS_URL }}
|
||||||
|
# API_REPORTER_METRICS_BASIC_AUTH_USERNAME: ${{ secrets.API_REPORTER_METRICS_BASIC_AUTH_USERNAME }}
|
||||||
|
# API_REPORTER_METRICS_BASIC_AUTH_PASSWORD: ${{ secrets.API_REPORTER_METRICS_BASIC_AUTH_PASSWORD }}
|
||||||
|
# API_REPORTER_DEBUG: false
|
||||||
|
|
||||||
|
# ADD YOUR CUSTOM ENV VARIABLES HERE TO OVERRIDE VALUES OF
|
||||||
|
# .mega-linter.yml AT THE ROOT OF YOUR REPOSITORY
|
||||||
|
|
||||||
|
# Upload MegaLinter artifacts
|
||||||
|
- name: Archive production artifacts
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
if: success() || failure()
|
||||||
|
with:
|
||||||
|
name: MegaLinter reports
|
||||||
|
include-hidden-files: "true"
|
||||||
|
path: |
|
||||||
|
megalinter-reports
|
||||||
|
mega-linter.log
|
||||||
|
|
||||||
|
# Create pull request if applicable
|
||||||
|
# (for now works only on PR from same repository, not from forks)
|
||||||
|
- name: Create Pull Request with applied fixes
|
||||||
|
uses: peter-evans/create-pull-request@v6
|
||||||
|
id: cpr
|
||||||
|
if: >-
|
||||||
|
steps.ml.outputs.has_updated_sources == 1 &&
|
||||||
|
(
|
||||||
|
env.APPLY_FIXES_EVENT == 'all' ||
|
||||||
|
env.APPLY_FIXES_EVENT == github.event_name
|
||||||
|
) &&
|
||||||
|
env.APPLY_FIXES_MODE == 'pull_request' &&
|
||||||
|
(
|
||||||
|
github.event_name == 'push' ||
|
||||||
|
github.event.pull_request.head.repo.full_name == github.repository
|
||||||
|
) &&
|
||||||
|
!contains(github.event.head_commit.message, 'skip fix')
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }}
|
||||||
|
commit-message: "[MegaLinter] Apply linters automatic fixes"
|
||||||
|
title: "[MegaLinter] Apply linters automatic fixes"
|
||||||
|
labels: bot
|
||||||
|
|
||||||
|
- name: Create PR output
|
||||||
|
if: >-
|
||||||
|
steps.ml.outputs.has_updated_sources == 1 &&
|
||||||
|
(
|
||||||
|
env.APPLY_FIXES_EVENT == 'all' ||
|
||||||
|
env.APPLY_FIXES_EVENT == github.event_name
|
||||||
|
) &&
|
||||||
|
env.APPLY_FIXES_MODE == 'pull_request' &&
|
||||||
|
(
|
||||||
|
github.event_name == 'push' ||
|
||||||
|
github.event.pull_request.head.repo.full_name == github.repository
|
||||||
|
) &&
|
||||||
|
!contains(github.event.head_commit.message, 'skip fix')
|
||||||
|
run: |
|
||||||
|
echo "PR Number - ${{ steps.cpr.outputs.pull-request-number }}"
|
||||||
|
echo "PR URL - ${{ steps.cpr.outputs.pull-request-url }}"
|
||||||
|
|
||||||
|
# Push new commit if applicable
|
||||||
|
# (for now works only on PR from same repository, not from forks)
|
||||||
|
- name: Prepare commit
|
||||||
|
if: >-
|
||||||
|
steps.ml.outputs.has_updated_sources == 1 &&
|
||||||
|
(
|
||||||
|
env.APPLY_FIXES_EVENT == 'all' ||
|
||||||
|
env.APPLY_FIXES_EVENT == github.event_name
|
||||||
|
) &&
|
||||||
|
env.APPLY_FIXES_MODE == 'commit' &&
|
||||||
|
github.ref != 'refs/heads/main' &&
|
||||||
|
(
|
||||||
|
github.event_name == 'push' ||
|
||||||
|
github.event.pull_request.head.repo.full_name == github.repository
|
||||||
|
) &&
|
||||||
|
!contains(github.event.head_commit.message, 'skip fix')
|
||||||
|
run: sudo chown -Rc $UID .git/
|
||||||
|
|
||||||
|
- name: Commit and push applied linter fixes
|
||||||
|
uses: stefanzweifel/git-auto-commit-action@v5
|
||||||
|
if: >-
|
||||||
|
steps.ml.outputs.has_updated_sources == 1 &&
|
||||||
|
(
|
||||||
|
env.APPLY_FIXES_EVENT == 'all' ||
|
||||||
|
env.APPLY_FIXES_EVENT == github.event_name
|
||||||
|
) &&
|
||||||
|
env.APPLY_FIXES_MODE == 'commit' &&
|
||||||
|
github.ref != 'refs/heads/main' &&
|
||||||
|
(
|
||||||
|
github.event_name == 'push' ||
|
||||||
|
github.event.pull_request.head.repo.full_name == github.repository
|
||||||
|
) &&
|
||||||
|
!contains(github.event.head_commit.message, 'skip fix')
|
||||||
|
with:
|
||||||
|
branch: >-
|
||||||
|
${{
|
||||||
|
github.event.pull_request.head.ref ||
|
||||||
|
github.head_ref ||
|
||||||
|
github.ref
|
||||||
|
}}
|
||||||
|
commit_message: "[MegaLinter] Apply linters fixes"
|
||||||
|
commit_user_name: megalinter-bot
|
||||||
|
commit_user_email: 129584137+megalinter-bot@users.noreply.github.com
|
||||||
|
|
||||||
|
# https://megalinter.io/latest/reporters/SarifReporter/
|
||||||
|
- name: Upload MegaLinter scan results to GitHub Security tab
|
||||||
|
if: success() || failure()
|
||||||
|
uses: github/codeql-action/upload-sarif@v3
|
||||||
|
with:
|
||||||
|
sarif_file: "megalinter-reports/megalinter-report.sarif"
|
||||||
|
category: mega-linter
|
||||||
|
|
||||||
|
# https://github.blog/news-insights/product-news/supercharging-github-actions-with-job-summaries/
|
||||||
|
- name: Add job summary
|
||||||
|
if: success() || failure()
|
||||||
|
run: cat "megalinter-reports/megalinter-report.md" >> "$GITHUB_STEP_SUMMARY"
|
||||||
|
|
||||||
|
# logs and artifacts are retained for 90 days, workflow run history is retained for 400 days... https://docs.github.com/en/actions/administering-github-actions/usage-limits-billing-and-administration#artifact-and-log-retention-policy
|
||||||
20
.github/workflows/sonar.yml
vendored
20
.github/workflows/sonar.yml
vendored
|
|
@ -15,27 +15,21 @@ jobs:
|
||||||
sonarcloud:
|
sonarcloud:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
-
|
- uses: actions/checkout@v4
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
with:
|
||||||
# Disabling shallow clone is recommended for improving relevancy of reporting. Otherwise sonarcloud will show a warning.
|
# Disabling shallow clone is recommended for improving relevancy of reporting. Otherwise sonarcloud will show a warning.
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
-
|
- uses: actions/setup-node@v4
|
||||||
uses: actions/setup-node@v4
|
|
||||||
with:
|
with:
|
||||||
cache: 'npm'
|
cache: "npm"
|
||||||
-
|
- name: Install dev dependencies which includde ESLint + plugins
|
||||||
name: Install dev dependencies which includde ESLint + plugins
|
|
||||||
run: npm install --only=dev
|
run: npm install --only=dev
|
||||||
-
|
- name: Run ESLint
|
||||||
name: Run ESLint
|
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
run: npx eslint . -f json -o eslint_report.json
|
run: npx eslint . -f json -o eslint_report.json
|
||||||
-
|
- name: Fix ESLint paths
|
||||||
name: Fix ESLint paths
|
|
||||||
run: sed -i 's+/home/runner/work/free-games-claimer/free-games-claimer+/github/workspace+g' eslint_report.json
|
run: sed -i 's+/home/runner/work/free-games-claimer/free-games-claimer+/github/workspace+g' eslint_report.json
|
||||||
-
|
- name: SonarCloud Scan
|
||||||
name: SonarCloud Scan
|
|
||||||
uses: sonarsource/sonarcloud-github-action@master
|
uses: sonarsource/sonarcloud-github-action@master
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
|
||||||
36
.github/workflows/super-linter.yml
vendored
36
.github/workflows/super-linter.yml
vendored
|
|
@ -1,36 +0,0 @@
|
||||||
# https://github.com/marketplace/actions/super-linter#get-started
|
|
||||||
name: Super-Linter
|
|
||||||
|
|
||||||
on: # yamllint disable-line rule:truthy
|
|
||||||
push: null
|
|
||||||
pull_request: null
|
|
||||||
|
|
||||||
permissions: {}
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
lint:
|
|
||||||
name: Super-Linter
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
packages: read
|
|
||||||
# To report GitHub Actions status checks
|
|
||||||
statuses: write
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checkout code
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
# super-linter needs the full git history to get the
|
|
||||||
# list of files that changed across commits
|
|
||||||
fetch-depth: 0
|
|
||||||
|
|
||||||
- name: Super-linter
|
|
||||||
uses: super-linter/super-linter/slim@v7.4.0 # x-release-please-version
|
|
||||||
# TODO need to create problem matchers for each linter? https://github.com/rhysd/actionlint/blob/v1.7.7/docs/usage.md#problem-matchers
|
|
||||||
env:
|
|
||||||
# To report GitHub Actions status checks
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
# TODO automatically fix linting issues and commit them for PRs
|
|
||||||
# fix-lint-issues: # https://github.com/marketplace/actions/super-linter#github-actions-workflow-example-pull-request
|
|
||||||
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -1,3 +1,5 @@
|
||||||
node_modules/
|
node_modules/
|
||||||
data/
|
data/
|
||||||
*.env
|
*.env
|
||||||
|
|
||||||
|
megalinter-reports/
|
||||||
|
|
|
||||||
15
.jscpd.json
Normal file
15
.jscpd.json
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
{
|
||||||
|
"threshold": 0,
|
||||||
|
"reporters": ["html", "markdown"],
|
||||||
|
"ignore": [
|
||||||
|
"**/node_modules/**",
|
||||||
|
"**/.git/**",
|
||||||
|
"**/.rbenv/**",
|
||||||
|
"**/.venv/**",
|
||||||
|
"**/*cache*/**",
|
||||||
|
"**/.github/**",
|
||||||
|
"**/.idea/**",
|
||||||
|
"**/report/**",
|
||||||
|
"**/*.svg"
|
||||||
|
]
|
||||||
|
}
|
||||||
84
.mega-linter.yml
Normal file
84
.mega-linter.yml
Normal file
|
|
@ -0,0 +1,84 @@
|
||||||
|
# Configuration file for MegaLinter
|
||||||
|
#
|
||||||
|
# See all available variables at https://megalinter.io/latest/config-file/ and in
|
||||||
|
# linters documentation
|
||||||
|
|
||||||
|
# See .github/workflows/mega-linter.yml for GitHub config.
|
||||||
|
|
||||||
|
# Run this locally via Docker:
|
||||||
|
# npx mega-linter-runner -r v8 -f cupcake # run as configured here
|
||||||
|
# npx mega-linter-runner -r v8 -f cupcake -e "'ENABLE=MARKDOWN,YAML'" -e "APPLY_FIXES=none" # only enable certain groups and disable automatic fixes (note that the '' are required for multiple values)
|
||||||
|
# npx mega-linter-runner -r v8 -f cupcake -e "ENABLE_LINTERS=MARKDOWN_MARKDOWN_LINK_CHECK" # run a specific linter
|
||||||
|
# https://github.com/oxsecurity/megalinter#cli-lint-mode most linters will respect .gitignore, but the ones running in 'project' mode will not and may take forever if not configured right
|
||||||
|
|
||||||
|
# all, none, or list of linter keys
|
||||||
|
APPLY_FIXES: all
|
||||||
|
|
||||||
|
# If you use ENABLE variable, all other languages/formats/tooling-formats will
|
||||||
|
# be disabled by default
|
||||||
|
# ENABLE:
|
||||||
|
|
||||||
|
# If you use ENABLE_LINTERS variable, all other linters will be disabled by
|
||||||
|
# default
|
||||||
|
# ENABLE_LINTERS:
|
||||||
|
|
||||||
|
# DISABLE:
|
||||||
|
# - COPYPASTE # Uncomment to disable checks of excessive copy-pastes
|
||||||
|
# - SPELL # Uncomment to disable checks of spelling mistakes
|
||||||
|
|
||||||
|
SHOW_ELAPSED_TIME: true
|
||||||
|
|
||||||
|
# Uncomment if you want MegaLinter to detect errors but not block CI to pass
|
||||||
|
# DISABLE_ERRORS: true
|
||||||
|
|
||||||
|
# ---
|
||||||
|
# Custom config:
|
||||||
|
|
||||||
|
PRINT_ALPACA: false
|
||||||
|
|
||||||
|
JAVASCRIPT_DEFAULT_STYLE: prettier # disables JAVASCRIPT_STANDARD in favor of JAVASCRIPT_PRETTIER - disabled below since I prefer my local eslint
|
||||||
|
|
||||||
|
# DISABLE: # groups of linters/formatters
|
||||||
|
# - REPOSITORY # ignore this for now (at least locally) since all project-based and need extra config like .gitignore
|
||||||
|
|
||||||
|
# npx mega-linter-runner -r v8 -f cupcake -e "ENABLE_LINTERS=MARKDOWN_MARKDOWN_LINK_CHECK" # run a specific linter locally
|
||||||
|
DISABLE_LINTERS: # times are for running locally with 30GB swap, 65% pressure and several GB in data/ (relevant for project-mode linters that don't respect .gitignore)
|
||||||
|
- MARKDOWN_MARKDOWN_LINK_CHECK # 30s, only reported 0 (e.g. for localhost) or 403 (forbidden) for working links to settings or due to DDoS/bot protections
|
||||||
|
- JAVASCRIPT_STANDARD # don't like standard format
|
||||||
|
- JAVASCRIPT_PRETTIER # prefer my local eslint config
|
||||||
|
- REPOSITORY_TRIVY_SBOM # 11s, don't need SBOM
|
||||||
|
|
||||||
|
DISABLE_ERRORS_LINTERS: # error -> warning
|
||||||
|
- DOCKERFILE_HADOLINT # mostly wants to pin versions for apt and pip installs and merge consecutive RUN instructions
|
||||||
|
- COPYPASTE_JSCPD # default threshold is 0% duplicates -> can make this error once sep. scripts are refactored
|
||||||
|
- SPELL_CSPELL # needs config in .cspell.json, but looks annoying since it also flags apt packages
|
||||||
|
- SPELL_LYCHEE # dead link checking, 9/332 errors all false positives (Forbidden etc.)
|
||||||
|
- JAVASCRIPT_ES # this uses old eslint 8.57.1 instead of local 9.26.0 and complains about stuff that newer version has no problem with
|
||||||
|
- REPOSITORY_CHECKOV # docker healthcheck not needed for CLI
|
||||||
|
- REPOSITORY_KICS # wants to pin GitHub Actions to commit sha etc.
|
||||||
|
- REPOSITORY_TRIVY # docker healthcheck not needed for CLI
|
||||||
|
|
||||||
|
# Customizations via CLI arguments:
|
||||||
|
|
||||||
|
# https://github.com/prantlf/jsonlint#command-line-interface
|
||||||
|
JSON_JSONLINT_ARGUMENTS: --comments --trailing-commas --no-duplicate-keys
|
||||||
|
|
||||||
|
# https://prettier.io/docs/options#trailing-commas
|
||||||
|
# JSON_PRETTIER_ARGUMENTS: --trailing-comma all --parser jsonc # need to change parser too since the default json parser still strips trailing commas
|
||||||
|
# -> let prettier remove trailing commas since e.g. npm will fail to JSON.parse package.json otherwise...
|
||||||
|
|
||||||
|
# megalinter still expects the old .eslintrc file... https://github.com/oxsecurity/megalinter/issues/3570#issuecomment-2138193684
|
||||||
|
JAVASCRIPT_ES_CONFIG_FILE: eslint.config.js
|
||||||
|
JAVASCRIPT_ES_COMMAND_REMOVE_ARGUMENTS: ["--no-eslintrc"] # not a valid option for eslint with flat config
|
||||||
|
# worked, but behaved differently than local `npm run lint` and complained about while(true) with break - probably due old version 8.57.1 (same with -r beta) instead of my local 9.26.0
|
||||||
|
|
||||||
|
# https://github.com/oxsecurity/megalinter#cli-lint-mode
|
||||||
|
REPOSITORY_SECRETLINT_ARGUMENTS: --secretlintignore .gitignore
|
||||||
|
|
||||||
|
# https://www.checkov.io/2.Basics/CLI%20Command%20Reference.html
|
||||||
|
REPOSITORY_CHECKOV_ARGUMENTS: --skip-path node_modules --skip-path data
|
||||||
|
|
||||||
|
# CI will comment on PRs etc., but for running locally (or downloading the results), we want more than the default megalinter-reports/megalinter.log as an overview:
|
||||||
|
JSON_REPORTER: true # mega-linter-report.json
|
||||||
|
MARKDOWN_SUMMARY_REPORTER: true # megalinter-report.md
|
||||||
|
SARIF_REPORTER: true # mega-linter-report.sarif - results for supported lintes should be shown in GitHub Security tab - https://megalinter.io/latest/reporters/SarifReporter/
|
||||||
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
|
|
@ -6,5 +6,5 @@
|
||||||
"source.fixAll.eslint": "explicit"
|
"source.fixAll.eslint": "explicit"
|
||||||
},
|
},
|
||||||
"eslint.experimental.useFlatConfig": true,
|
"eslint.experimental.useFlatConfig": true,
|
||||||
"eslint.codeActionsOnSave.rules": null,
|
"eslint.codeActionsOnSave.rules": null
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,12 @@
|
||||||
|
|
||||||
## Code: how to create a pull request
|
## Code: how to create a pull request
|
||||||
|
|
||||||
1. Fork it ( https://github.com/vogler/free-games-claimer/fork ).
|
1. Fork it ( <https://github.com/vogler/free-games-claimer/fork> ).
|
||||||
1. Create your feature branch (`git checkout -b my-new-feature`).
|
1. Create your feature branch (`git checkout -b my-new-feature`).
|
||||||
1. Stage your files (`git add .`).
|
1. Stage your files (`git add .`).
|
||||||
1. Commit your changes (`git commit -am 'Add some feature'`).
|
1. Commit your changes (`git commit -am 'Add some feature'`).
|
||||||
1. Push to the branch (`git push origin my-new-feature`).
|
1. Push to the branch (`git push origin my-new-feature`).
|
||||||
1. Create a new pull request ( https://github.com/vogler/free-games-claimer/compare ).
|
1. Create a new pull request ( <https://github.com/vogler/free-games-claimer/compare> ).
|
||||||
|
|
||||||
|
|
||||||
## Building and publishing docker images
|
## Building and publishing docker images
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ If you don't want to use Docker for quasi-headless mode, you could run inside a
|
||||||
## Usage
|
## Usage
|
||||||
All scripts start an automated Firefox instance, either with the browser GUI shown or hidden (_headless mode_). By default, you won't see any browser open on your host system.
|
All scripts start an automated Firefox instance, either with the browser GUI shown or hidden (_headless mode_). By default, you won't see any browser open on your host system.
|
||||||
|
|
||||||
- When running inside Docker, the browser will be shown only inside the container. You can open http://localhost:6080 to interact with the browser running inside the container via noVNC (or use other VNC clients on port 5900).
|
- When running inside Docker, the browser will be shown only inside the container. You can open <http://localhost:6080> to interact with the browser running inside the container via noVNC (or use other VNC clients on port 5900).
|
||||||
- When running the scripts outside of Docker, the browser will be hidden by default; you can use `SHOW=1 ...` to show the UI (see options below).
|
- When running the scripts outside of Docker, the browser will be hidden by default; you can use `SHOW=1 ...` to show the UI (see options below).
|
||||||
|
|
||||||
When running the first time, you have to login for each store you want to claim games on.
|
When running the first time, you have to login for each store you want to claim games on.
|
||||||
|
|
@ -68,7 +68,7 @@ TODO: ~~On the first run, the script will guide you through configuration and sa
|
||||||
Available options/variables and their default values:
|
Available options/variables and their default values:
|
||||||
|
|
||||||
| Option | Default | Description |
|
| Option | Default | Description |
|
||||||
|-----------------|--------------|------------------------------------------------------------------------------|
|
|----------------|--------------|------------------------------------------------------------------------------------------------------------------------------|
|
||||||
| SHOW | 1 | Show browser if 1. Default for Docker, not shown when running outside. |
|
| SHOW | 1 | Show browser if 1. Default for Docker, not shown when running outside. |
|
||||||
| WIDTH | 1280 | Width of the opened browser (and of screen for VNC in Docker). |
|
| WIDTH | 1280 | Width of the opened browser (and of screen for VNC in Docker). |
|
||||||
| HEIGHT | 1280 | Height of the opened browser (and of screen for VNC in Docker). |
|
| HEIGHT | 1280 | Height of the opened browser (and of screen for VNC in Docker). |
|
||||||
|
|
@ -114,7 +114,7 @@ You can also put options in `data/config.env` which will be loaded by [dotenv](h
|
||||||
The scripts will try to send notifications for successfully claimed games and any errors like needing to log in or encountered captchas (should not happen).
|
The scripts will try to send notifications for successfully claimed games and any errors like needing to log in or encountered captchas (should not happen).
|
||||||
|
|
||||||
[apprise](https://github.com/caronc/apprise) is used for notifications and offers many services including Pushover, Slack, Telegram, SMS, Email, desktop and custom notifications.
|
[apprise](https://github.com/caronc/apprise) is used for notifications and offers many services including Pushover, Slack, Telegram, SMS, Email, desktop and custom notifications.
|
||||||
You just need to set `NOTIFY` to the notification services you want to use, e.g. `NOTIFY='mailto://myemail:mypass@gmail.com' 'pbul://o.gn5kj6nfhv736I7jC3cj3QLRiyhgl98b'` - refer to their list of services and [examples](https://github.com/caronc/apprise#command-line-usage).
|
You just need to set `NOTIFY` to the notification services you want to use, e.g. `NOTIFY='mailto://myemail@gmail.com' 'pbul://o.gn5kj6nfhv736I7jC3cj3QLRiyhgl98b'` - refer to their list of services and [examples](https://github.com/caronc/apprise#command-line-usage).
|
||||||
|
|
||||||
### Automatic login, two-factor authentication
|
### Automatic login, two-factor authentication
|
||||||
If you set the options for email, password and OTP key, there will be no prompts and logins should happen automatically. This is optional since all stores should stay logged in since cookies are refreshed.
|
If you set the options for email, password and OTP key, there will be no prompts and logins should happen automatically. This is optional since all stores should stay logged in since cookies are refreshed.
|
||||||
|
|
@ -160,6 +160,7 @@ If you want it to run regularly, you have to schedule the runs yourself:
|
||||||
|
|
||||||
- Linux/macOS: `crontab -e` ([example](https://github.com/vogler/free-games-claimer/discussions/56))
|
- Linux/macOS: `crontab -e` ([example](https://github.com/vogler/free-games-claimer/discussions/56))
|
||||||
- macOS: [launchd](https://stackoverflow.com/questions/132955/how-do-i-set-a-task-to-run-every-so-often)
|
- macOS: [launchd](https://stackoverflow.com/questions/132955/how-do-i-set-a-task-to-run-every-so-often)
|
||||||
|
<!-- markdownlint-disable-next-line line-length -->
|
||||||
- Windows: [task scheduler](https://active-directory-wp.com/docs/Usage/How_to_add_a_cron_job_on_Windows/Scheduled_tasks_and_cron_jobs_on_Windows/index.html) ([example](https://github.com/vogler/free-games-claimer/wiki/%5BHowTo%5D-Schedule-runs-on-Windows)), [other options](https://stackoverflow.com/questions/132971/what-is-the-windows-version-of-cron), or just put the command in a `.bat` file in Autostart if you restart often...
|
- Windows: [task scheduler](https://active-directory-wp.com/docs/Usage/How_to_add_a_cron_job_on_Windows/Scheduled_tasks_and_cron_jobs_on_Windows/index.html) ([example](https://github.com/vogler/free-games-claimer/wiki/%5BHowTo%5D-Schedule-runs-on-Windows)), [other options](https://stackoverflow.com/questions/132971/what-is-the-windows-version-of-cron), or just put the command in a `.bat` file in Autostart if you restart often...
|
||||||
- any OS: use a process manager like [pm2](https://pm2.keymetrics.io/docs/usage/restart-strategies/)
|
- any OS: use a process manager like [pm2](https://pm2.keymetrics.io/docs/usage/restart-strategies/)
|
||||||
- Docker Compose `command: bash -c "node epic-games; node prime-gaming; node gog; echo sleeping; sleep 1d"` additionally add `restart: unless-stopped` to it.
|
- Docker Compose `command: bash -c "node epic-games; node prime-gaming; node gog; echo sleeping; sleep 1d"` additionally add `restart: unless-stopped` to it.
|
||||||
|
|
@ -182,6 +183,7 @@ Tried [epicgames-freebies-claimer](https://github.com/Revadike/epicgames-freebie
|
||||||
Played around with Puppeteer before, now trying newer [Playwright](https://playwright.dev) which is pretty similar.
|
Played around with Puppeteer before, now trying newer [Playwright](https://playwright.dev) which is pretty similar.
|
||||||
Playwright Inspector and `codegen` to generate scripts are nice, but failed to generate the right code for clicking a button in an iframe.
|
Playwright Inspector and `codegen` to generate scripts are nice, but failed to generate the right code for clicking a button in an iframe.
|
||||||
|
|
||||||
|
<!-- markdownlint-disable-next-line line-length -->
|
||||||
Added [main.spec.ts](https://github.com/vogler/epicgames-claimer/commit/e5ce7916ab6329cfc7134677c4d89c2b3fa3ba97#diff-d18d03e9c407a20e05fbf03cbd6f9299857740544fb6b50d6a70b9c6fbc35831) which was the test script generated by `npx playwright codegen` with manual fix for clicking buttons in the created iframe. Can be executed by `npx playwright test`. The test runner has options `--debug` and `--timeout` and can execute TypeScript which is nice. However, this only worked up to the button 'I Agree', and then showed an hcaptcha.
|
Added [main.spec.ts](https://github.com/vogler/epicgames-claimer/commit/e5ce7916ab6329cfc7134677c4d89c2b3fa3ba97#diff-d18d03e9c407a20e05fbf03cbd6f9299857740544fb6b50d6a70b9c6fbc35831) which was the test script generated by `npx playwright codegen` with manual fix for clicking buttons in the created iframe. Can be executed by `npx playwright test`. The test runner has options `--debug` and `--timeout` and can execute TypeScript which is nice. However, this only worked up to the button 'I Agree', and then showed an hcaptcha.
|
||||||
|
|
||||||
Added [main.captcha.js](https://github.com/vogler/epicgames-claimer/commit/e5ce7916ab6329cfc7134677c4d89c2b3fa3ba97#diff-d18d03e9c407a20e05fbf03cbd6f9299857740544fb6b50d6a70b9c6fbc35831) which uses beta of `playwright-extra@next` and `@extra/recaptcha@next` (from [comment on puppeteer-extra](https://github.com/berstend/puppeteer-extra/pull/303#issuecomment-775277480)).
|
Added [main.captcha.js](https://github.com/vogler/epicgames-claimer/commit/e5ce7916ab6329cfc7134677c4d89c2b3fa3ba97#diff-d18d03e9c407a20e05fbf03cbd6f9299857740544fb6b50d6a70b9c6fbc35831) which uses beta of `playwright-extra@next` and `@extra/recaptcha@next` (from [comment on puppeteer-extra](https://github.com/berstend/puppeteer-extra/pull/303#issuecomment-775277480)).
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ export default [
|
||||||
// object with just `ignores` applies to all configuration objects
|
// object with just `ignores` applies to all configuration objects
|
||||||
// had `ln -s .gitignore .eslintignore` before, but .eslintignore no longer supported
|
// had `ln -s .gitignore .eslintignore` before, but .eslintignore no longer supported
|
||||||
{
|
{
|
||||||
ignores: ['data/**'],
|
ignores: ['data/**', 'megalinter-reports/**'],
|
||||||
},
|
},
|
||||||
js.configs.recommended, // TODO still needed?
|
js.configs.recommended, // TODO still needed?
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
"checkJs": true,
|
"checkJs": true,
|
||||||
"target": "es2021",
|
"target": "es2021",
|
||||||
"module": "NodeNext",
|
"module": "NodeNext",
|
||||||
"moduleResolution": "NodeNext", // https://github.com/typicode/lowdb/issues/554
|
"moduleResolution": "NodeNext" // https://github.com/typicode/lowdb/issues/554
|
||||||
},
|
},
|
||||||
"exclude": ["node_modules", "**/node_modules"]
|
"exclude": ["node_modules", "**/node_modules"]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue