fix: resolve ReferenceError in github-script actions by using environ… #4
This file contains hidden or 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: Check for Dependency Updates | |
| # This workflow checks for new versions of dependencies hardcoded in installer scripts | |
| # and creates an issue to track updates that need to be made manually | |
| on: | |
| schedule: | |
| # Run every Monday at 9:00 AM UTC | |
| - cron: '0 9 * * 1' | |
| workflow_dispatch: # Allow manual triggering | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - '.github/workflows/check-dependencies.yml' | |
| permissions: | |
| contents: read | |
| issues: write | |
| jobs: | |
| check-nginx-deps: | |
| name: Check NGINX Dependencies | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| - name: Check NGINX version | |
| id: nginx | |
| run: | | |
| CURRENT_VERSION=$(grep -oP 'NGINX_VERSION="\K[^"]+' nginx/nginx_installer.sh) | |
| echo "current=$CURRENT_VERSION" >> $GITHUB_OUTPUT | |
| # Get latest version from nginx.org | |
| LATEST_VERSION=$(curl -sL https://nginx.org/en/download.html | grep -oP 'nginx-\K[0-9]+\.[0-9]+\.[0-9]+(?=\.tar\.gz)' | head -n1) | |
| echo "latest=$LATEST_VERSION" >> $GITHUB_OUTPUT | |
| if [ "$CURRENT_VERSION" != "$LATEST_VERSION" ]; then | |
| echo "update_needed=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "update_needed=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Check OpenSSL version | |
| id: openssl | |
| run: | | |
| CURRENT_VERSION=$(grep -oP 'OPENSSL_VERSION="\K[^"]+' nginx/nginx_installer.sh) | |
| echo "current=$CURRENT_VERSION" >> $GITHUB_OUTPUT | |
| # Get latest version from GitHub releases | |
| LATEST_VERSION=$(curl -sL -H "Authorization: Bearer ${{ github.token }}" -H "Accept: application/vnd.github+json" https://api.github.com/repos/openssl/openssl/releases/latest | jq -r '.tag_name' | sed 's/openssl-//') | |
| echo "latest=$LATEST_VERSION" >> $GITHUB_OUTPUT | |
| if [ "$CURRENT_VERSION" != "$LATEST_VERSION" ]; then | |
| echo "update_needed=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "update_needed=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Check PCRE2 version | |
| id: pcre2 | |
| run: | | |
| CURRENT_VERSION=$(grep -oP 'PCRE2_VERSION="\K[^"]+' nginx/nginx_installer.sh) | |
| echo "current=$CURRENT_OUTPUT" >> $GITHUB_OUTPUT | |
| # Get latest version from GitHub releases | |
| LATEST_VERSION=$(curl -sL -H "Authorization: Bearer ${{ github.token }}" -H "Accept: application/vnd.github+json" https://api.github.com/repos/PCRE2Project/pcre2/releases/latest | jq -r '.tag_name' | sed 's/pcre2-//') | |
| echo "latest=$LATEST_VERSION" >> $GITHUB_OUTPUT | |
| if [ "$CURRENT_VERSION" != "$LATEST_VERSION" ]; then | |
| echo "update_needed=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "update_needed=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Check Zlib version | |
| id: zlib | |
| run: | | |
| CURRENT_VERSION=$(grep -oP 'ZLIB_VERSION="\K[^"]+' nginx/nginx_installer.sh) | |
| echo "current=$CURRENT_VERSION" >> $GITHUB_OUTPUT | |
| # Get latest version from GitHub releases | |
| LATEST_VERSION=$(curl -sL -H "Authorization: Bearer ${{ github.token }}" -H "Accept: application/vnd.github+json" https://api.github.com/repos/madler/zlib/releases/latest | jq -r '.tag_name' | sed 's/v//') | |
| echo "latest=$LATEST_VERSION" >> $GITHUB_OUTPUT | |
| if [ "$CURRENT_VERSION" != "$LATEST_VERSION" ]; then | |
| echo "update_needed=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "update_needed=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Create or update issue | |
| if: | | |
| steps.nginx.outputs.update_needed == 'true' || | |
| steps.openssl.outputs.update_needed == 'true' || | |
| steps.pcre2.outputs.update_needed == 'true' || | |
| steps.zlib.outputs.update_needed == 'true' | |
| uses: actions/github-script@v8 | |
| env: | |
| NGINX_UPDATE_NEEDED: ${{ steps.nginx.outputs.update_needed }} | |
| NGINX_CURRENT: ${{ steps.nginx.outputs.current }} | |
| NGINX_LATEST: ${{ steps.nginx.outputs.latest }} | |
| OPENSSL_UPDATE_NEEDED: ${{ steps.openssl.outputs.update_needed }} | |
| OPENSSL_CURRENT: ${{ steps.openssl.outputs.current }} | |
| OPENSSL_LATEST: ${{ steps.openssl.outputs.latest }} | |
| PCRE2_UPDATE_NEEDED: ${{ steps.pcre2.outputs.update_needed }} | |
| PCRE2_CURRENT: ${{ steps.pcre2.outputs.current }} | |
| PCRE2_LATEST: ${{ steps.pcre2.outputs.latest }} | |
| ZLIB_UPDATE_NEEDED: ${{ steps.zlib.outputs.update_needed }} | |
| ZLIB_CURRENT: ${{ steps.zlib.outputs.current }} | |
| ZLIB_LATEST: ${{ steps.zlib.outputs.latest }} | |
| with: | |
| script: | | |
| const issueTitle = '🔄 NGINX Dependencies Update Available'; | |
| const issueBody = `## NGINX Installer Dependencies Update | |
| The following dependencies have updates available: | |
| ${process.env.NGINX_UPDATE_NEEDED === 'true' ? `- **NGINX**: ${process.env.NGINX_CURRENT} → ${process.env.NGINX_LATEST}` : ''} | |
| ${process.env.OPENSSL_UPDATE_NEEDED === 'true' ? `- **OpenSSL**: ${process.env.OPENSSL_CURRENT} → ${process.env.OPENSSL_LATEST}` : ''} | |
| ${process.env.PCRE2_UPDATE_NEEDED === 'true' ? `- **PCRE2**: ${process.env.PCRE2_CURRENT} → ${process.env.PCRE2_LATEST}` : ''} | |
| ${process.env.ZLIB_UPDATE_NEEDED === 'true' ? `- **Zlib**: ${process.env.ZLIB_CURRENT} → ${process.env.ZLIB_LATEST}` : ''} | |
| ### Files to update: | |
| - \`nginx/nginx_installer.sh\` | |
| - \`nginx/nginx_installer.ps1\` (if applicable) | |
| ### Update steps: | |
| 1. Update version numbers in the scripts | |
| 2. Download the new tarballs and calculate SHA256 checksums | |
| 3. Update the SHA256 hashes in the scripts | |
| 4. Test the installation on a clean system | |
| --- | |
| *This issue was automatically created by the dependency check workflow.* | |
| *Last checked: ${new Date().toISOString()}*`; | |
| // Search for existing issue | |
| const issues = await github.rest.issues.listForRepo({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| state: 'open', | |
| labels: 'dependencies,nginx' | |
| }); | |
| const existingIssue = issues.data.find(issue => issue.title === issueTitle); | |
| if (existingIssue) { | |
| // Update existing issue | |
| await github.rest.issues.update({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: existingIssue.number, | |
| body: issueBody | |
| }); | |
| console.log(`Updated issue #${existingIssue.number}`); | |
| } else { | |
| // Create new issue | |
| await github.rest.issues.create({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| title: issueTitle, | |
| body: issueBody, | |
| labels: ['dependencies', 'nginx', 'enhancement'] | |
| }); | |
| console.log('Created new issue'); | |
| } | |
| check-ansible-deps: | |
| name: Check Ansible Dependencies | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| - name: Check Python version | |
| id: python | |
| run: | | |
| CURRENT_VERSION=$(grep -oP 'BUILD_PYTHON_VERSION:-\K[^}]+' ansible/ansible_installer.sh) | |
| echo "current=$CURRENT_VERSION" >> $GITHUB_OUTPUT | |
| # Get latest Python 3.14.x version | |
| LATEST_VERSION=$(curl -sL https://www.python.org/ftp/python/ | grep -oP '3\.14\.\d+' | sort -V | tail -n1) | |
| echo "latest=$LATEST_VERSION" >> $GITHUB_OUTPUT | |
| if [ "$CURRENT_VERSION" != "$LATEST_VERSION" ]; then | |
| echo "update_needed=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "update_needed=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Check Ansible version | |
| id: ansible | |
| run: | | |
| # Extract Ansible version from the pip install line | |
| CURRENT_VERSION=$(grep -oP 'pip install ansible==\K[0-9.]+' ansible/ansible_installer.sh) | |
| LATEST_VERSION=$(curl -sL https://pypi.org/pypi/ansible/json | jq -r '.info.version') | |
| echo "current=$CURRENT_VERSION" >> $GITHUB_OUTPUT | |
| echo "latest=$LATEST_VERSION" >> $GITHUB_OUTPUT | |
| if [ "$CURRENT_VERSION" != "$LATEST_VERSION" ]; then | |
| echo "update_needed=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "update_needed=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Create or update issue | |
| if: | | |
| steps.python.outputs.update_needed == 'true' || | |
| steps.ansible.outputs.update_needed == 'true' | |
| uses: actions/github-script@v8 | |
| env: | |
| PYTHON_UPDATE_NEEDED: ${{ steps.python.outputs.update_needed }} | |
| PYTHON_CURRENT: ${{ steps.python.outputs.current }} | |
| PYTHON_LATEST: ${{ steps.python.outputs.latest }} | |
| ANSIBLE_UPDATE_NEEDED: ${{ steps.ansible.outputs.update_needed }} | |
| ANSIBLE_CURRENT: ${{ steps.ansible.outputs.current }} | |
| ANSIBLE_LATEST: ${{ steps.ansible.outputs.latest }} | |
| with: | |
| script: | | |
| const issueTitle = '🔄 Ansible Dependencies Update Available'; | |
| const issueBody = `## Ansible Installer Dependencies Update | |
| The following dependencies have updates available: | |
| ${process.env.PYTHON_UPDATE_NEEDED === 'true' ? `- **Python**: ${process.env.PYTHON_CURRENT} → ${process.env.PYTHON_LATEST}` : ''} | |
| ${process.env.ANSIBLE_UPDATE_NEEDED === 'true' ? `- **Ansible**: ${process.env.ANSIBLE_CURRENT} → ${process.env.ANSIBLE_LATEST}` : ''} | |
| ### Files to update: | |
| - \`ansible/ansible_installer.sh\` | |
| ### Update steps: | |
| 1. Update \`BUILD_PYTHON_VERSION\` and/or Ansible version in the script | |
| 2. Test the installation on a clean system | |
| 3. Verify Ansible functionality after installation | |
| --- | |
| *This issue was automatically created by the dependency check workflow.* | |
| *Last checked: ${new Date().toISOString()}*`; | |
| // Search for existing issue | |
| const issues = await github.rest.issues.listForRepo({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| state: 'open', | |
| labels: 'dependencies,ansible' | |
| }); | |
| const existingIssue = issues.data.find(issue => issue.title === issueTitle); | |
| if (existingIssue) { | |
| await github.rest.issues.update({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: existingIssue.number, | |
| body: issueBody | |
| }); | |
| console.log(`Updated issue #${existingIssue.number}`); | |
| } else { | |
| await github.rest.issues.create({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| title: issueTitle, | |
| body: issueBody, | |
| labels: ['dependencies', 'ansible', 'enhancement'] | |
| }); | |
| console.log('Created new issue'); | |
| } | |
| check-docker: | |
| name: Check Docker Installation | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| - name: Verify Docker installer | |
| run: | | |
| echo "Docker installer uses official Docker repositories, which provide latest versions." | |
| echo "No hardcoded versions to check." | |
| summary: | |
| name: Summary | |
| runs-on: ubuntu-latest | |
| needs: [check-nginx-deps, check-ansible-deps, check-docker] | |
| if: always() | |
| steps: | |
| - name: Summary | |
| run: | | |
| NGINX_RESULT="${{ needs.check-nginx-deps.result }}" | |
| ANSIBLE_RESULT="${{ needs.check-ansible-deps.result }}" | |
| DOCKER_RESULT="${{ needs.check-docker.result }}" | |
| echo "### Dependency Check Summary" >> "$GITHUB_STEP_SUMMARY" | |
| echo "" >> "$GITHUB_STEP_SUMMARY" | |
| if [ "$NGINX_RESULT" = "success" ] && [ "$ANSIBLE_RESULT" = "success" ] && [ "$DOCKER_RESULT" = "success" ]; then | |
| echo "✅ All dependency checks completed successfully." >> "$GITHUB_STEP_SUMMARY" | |
| else | |
| echo "⚠️ Some dependency checks did not complete successfully. See details below." >> "$GITHUB_STEP_SUMMARY" | |
| fi | |
| echo "" >> "$GITHUB_STEP_SUMMARY" | |
| echo "| Check | Result |" >> "$GITHUB_STEP_SUMMARY" | |
| echo "|-----------------------|----------|" >> "$GITHUB_STEP_SUMMARY" | |
| echo "| NGINX dependencies | $NGINX_RESULT |" >> "$GITHUB_STEP_SUMMARY" | |
| echo "| Ansible dependencies | $ANSIBLE_RESULT |" >> "$GITHUB_STEP_SUMMARY" | |
| echo "| Docker installation | $DOCKER_RESULT |" >> "$GITHUB_STEP_SUMMARY" | |
| echo "" >> "$GITHUB_STEP_SUMMARY" | |
| echo "If any updates are needed, issues have been created or updated automatically." >> "$GITHUB_STEP_SUMMARY" |