diff --git a/.github/workflows/actions_release.yml b/.github/workflows/actions_release.yml new file mode 100644 index 0000000..2a60975 --- /dev/null +++ b/.github/workflows/actions_release.yml @@ -0,0 +1,27 @@ +name: Release GitHub Actions + +on: + workflow_dispatch: + inputs: + tag: + description: "Tag for the release" + required: true + node_version: + description: "Node.js version to use" + required: false + default: "24" + +permissions: + contents: read + +jobs: + release: + permissions: + actions: read + id-token: write + contents: write + + uses: step-security/reusable-workflows/.github/workflows/actions_release.yaml@v1 + with: + tag: "${{ github.event.inputs.tag }}" + node_version: ${{ inputs.node_version || '24' }} \ No newline at end of file diff --git a/.github/workflows/audit_package.yml b/.github/workflows/audit_package.yml new file mode 100644 index 0000000..7a38506 --- /dev/null +++ b/.github/workflows/audit_package.yml @@ -0,0 +1,32 @@ +name: NPM Audit Fix Run + +on: + workflow_dispatch: + inputs: + force: + description: "Use --force flag for npm audit fix?" + required: true + type: boolean + base_branch: + description: "Specify a base branch" + required: false + default: "main" + node_version: + description: "Node.js version to use" + required: false + default: "24" + schedule: + - cron: "0 0 * * 1" + +jobs: + audit-fix: + uses: step-security/reusable-workflows/.github/workflows/audit_fix.yml@v1 + with: + force: ${{ inputs.force || false }} + base_branch: ${{ inputs.base_branch || 'main' }} + node_version: ${{ inputs.node_version || '24' }} +permissions: + contents: write + pull-requests: write + packages: read + issues: write diff --git a/.github/workflows/auto_cherry_pick.yml b/.github/workflows/auto_cherry_pick.yml new file mode 100644 index 0000000..be4743b --- /dev/null +++ b/.github/workflows/auto_cherry_pick.yml @@ -0,0 +1,42 @@ +name: Auto Cherry-Pick from Upstream + +on: + workflow_run: + workflows: ["Release GitHub Actions"] + types: + - completed + + workflow_dispatch: + inputs: + base_branch: + description: "Base branch to create the PR against" + required: true + default: "main" + mode: + description: "Run mode: cherry-pick or verify" + required: false + default: "cherry-pick" + node_version: + description: "Node.js version to use" + required: false + default: "24" + + pull_request: + types: [opened, synchronize, labeled] + +permissions: + contents: write + pull-requests: write + packages: read + issues: write + +jobs: + cherry-pick: + if: (github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success') || github.event_name == 'workflow_dispatch' || contains(fromJson(toJson(github.event.pull_request.labels)).*.name, 'review-required') + uses: step-security/reusable-workflows/.github/workflows/auto_cherry_pick.yaml@v1 + with: + original-owner: "shivammathur" + repo-name: "setup-php" + base_branch: ${{ inputs.base_branch || 'main' }} + mode: ${{ github.event_name == 'pull_request' && 'verify' || inputs.mode || 'cherry-pick' }} + node_version: ${{ inputs.node_version || '24' }} \ No newline at end of file diff --git a/.github/workflows/node.yml b/.github/workflows/node.yml new file mode 100644 index 0000000..0995b2b --- /dev/null +++ b/.github/workflows/node.yml @@ -0,0 +1,47 @@ +name: Node workflow +on: + pull_request: + branches: + - main + paths-ignore: + - '**.md' + - 'examples/**' + push: + branches: + - main + paths-ignore: + - '**.md' + - 'examples/**' +permissions: + contents: read + +jobs: + run: + name: Run + runs-on: ${{ matrix.operating-system }} + strategy: + fail-fast: false + matrix: + operating-system: ${{ github.actor == 'dependabot[bot]' && fromJson('["ubuntu-latest"]') || fromJson('["ubuntu-latest", "windows-latest", "macos-latest"]') }} + steps: + - name: Checkout + uses: actions/checkout@v6 + with: + fetch-depth: 2 + + - name: Setup Node.js 24.x + uses: actions/setup-node@v6 + with: + node-version: 24.x + + - name: Install dependencies + run: npm install + + - name: Prettier Format Check + run: npm run format-check + + - name: ESLint Check + run: npm run lint + + - name: Run tests + run: npm test diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml new file mode 100644 index 0000000..e8dc057 --- /dev/null +++ b/.github/workflows/php.yml @@ -0,0 +1,89 @@ +name: Main workflow +on: + workflow_dispatch: + pull_request: + branches: + - main + paths-ignore: + - '**.md' + - 'examples/**' + push: + branches: + - main + paths-ignore: + - '**.md' + - 'examples/**' +permissions: + contents: read +env: + default-php-version: '8.2' +jobs: + run: + name: Run + runs-on: ${{ matrix.operating-system }} + strategy: + fail-fast: false + matrix: + operating-system: ${{ github.actor == 'dependabot[bot]' && fromJson('["ubuntu-24.04"]') || fromJson('["ubuntu-24.04", "ubuntu-22.04", "windows-2022", "macos-15-intel"]') }} + php-versions: ${{ github.actor == 'dependabot[bot]' && fromJson('["8.6"]') || fromJson('["5.3", "5.4", "5.5", "5.6", "7.0", "7.1", "7.2", "7.3", "7.4", "8.0", "8.1", "8.2", "8.3", "8.4", "8.5", "8.6"]') }} + include: + - operating-system: ubuntu-24.04 + php-versions: '' + php-version-file: 'php-version-file' + env: + extensions: xml, opcache, xdebug, pcov, gd + key: cache-v5 + steps: + - name: Checkout + uses: actions/checkout@v6 + + - name: Setup cache environment + id: cache-env + uses: shivammathur/cache-extensions@v1 + with: + php-version: ${{ matrix.php-versions || env.default-php-version }} + extensions: ${{ env.extensions }} + key: ${{ env.key }} + + - name: Cache extensions + uses: actions/cache@v5 + with: + path: ${{ steps.cache-env.outputs.dir }} + key: ${{ steps.cache-env.outputs.key }} + restore-keys: ${{ steps.cache-env.outputs.key }} + + - name: Stage php-version-file + if: ${{ matrix.php-version-file == 'php-version-file' }} + run: | + echo ${{ env.default-php-version }} > php-version-file + + - name: Setup PHP with extensions and custom config + run: node dist/index.js + env: + php-version: ${{ matrix.php-versions }} + php-version-file: ${{ matrix.php-version-file }} + extensions: ${{ env.extensions }} + ini-values: post_max_size=256M, short_open_tag=On, date.timezone=Asia/Kolkata + + - name: Testing PHP version + run: | + php -v + php -r "if(strpos(phpversion(), '${{ matrix.php-versions || env.default-php-version }}') === false) {throw new Exception('Wrong PHP version Installed');}" + + - name: Testing Composer version + run: | + composer -V + php -r "if(strpos(@exec('composer -V'), 'Composer version') === false) {throw new Exception('Composer not found');}" + - name: Testing Extensions + run: | + php -m + php -r "if(! extension_loaded('gd')) {throw new Exception('gd not found');}" + php -r "if(! extension_loaded('xml')) {throw new Exception('xml not found');}" + php -r "if(! extension_loaded('Xdebug')) {throw new Exception('Xdebug not found');}" + php -r "if(phpversion()>=7.1 && ! extension_loaded('pcov')) {throw new Exception('PCOV not found');}" + - name: Testing ini values + run: | + php -r "if(ini_get('memory_limit')!='-1') {throw new Exception('memory_limit not disabled');}" + php -r "if(ini_get('post_max_size')!='256M') {throw new Exception('post_max_size not added');}" + php -r "if(ini_get('short_open_tag')!=1) {throw new Exception('short_open_tag not added');}" + php -r "if(ini_get('date.timezone')!='Asia/Kolkata') {throw new Exception('date.timezone not added');}" diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d0010af --- /dev/null +++ b/.gitignore @@ -0,0 +1,93 @@ +# Explicitly not ignoring node_modules so that they are included in package downloaded by runner +node_modules/ +__tests__/runner/* +lib/ + +# Rest of the file pulled from https://github.com/github/gitignore/blob/main/Node.gitignore +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +lerna-debug.log* + +# Diagnostic reports (https://nodejs.org/api/report.html) +report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage +*.lcov + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +jspm_packages/ + +# TypeScript v1 declaration files +typings/ + +# TypeScript cache +*.tsbuildinfo + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variables file +.env +.env.test + +# parcel-bundler cache (https://parceljs.org/) +.cache + +# next.js build output +.next + +# nuxt.js build output +.nuxt + +# vuepress build output +.vuepress/dist + +# Serverless directories +.serverless/ + +# FuseBox cache +.fusebox/ + +# DynamoDB Local files +.dynamodb/ \ No newline at end of file diff --git a/.node-version b/.node-version new file mode 100644 index 0000000..cabf43b --- /dev/null +++ b/.node-version @@ -0,0 +1 @@ +24 \ No newline at end of file diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..78c50d2 --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +min-release-age=3 \ No newline at end of file diff --git a/.prettierrc.json b/.prettierrc.json new file mode 100644 index 0000000..966db1e --- /dev/null +++ b/.prettierrc.json @@ -0,0 +1,12 @@ +{ + "arrowParens": "avoid", + "bracketSpacing": false, + "endOfLine": "auto", + "parser": "typescript", + "printWidth": 80, + "semi": true, + "singleQuote": true, + "tabWidth": 2, + "trailingComma": "none", + "useTabs": false +} \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..6f5523c --- /dev/null +++ b/LICENSE @@ -0,0 +1,22 @@ +The MIT License (MIT) + +Copyright (c) shivammathur and contributors +Copyright (c) 2026 Step Security, Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/README.md b/README.md index 66bffd5..d6bee3d 100644 --- a/README.md +++ b/README.md @@ -1 +1,1028 @@ -# setup-php \ No newline at end of file +[](https://docs.stepsecurity.io/actions/stepsecurity-maintained-actions) + + +