|
| 1 | +name: Nix Dependency Analysis |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + paths: |
| 6 | + - "flake.lock" |
| 7 | + - "flake.nix" |
| 8 | + - "nix/**" |
| 9 | + - "ci/**" |
| 10 | + - ".github/workflows/nix-dependency-analysis.yml" |
| 11 | + workflow_dispatch: |
| 12 | + inputs: |
| 13 | + pr_number: |
| 14 | + description: "PR number to analyze" |
| 15 | + required: false |
| 16 | + type: number |
| 17 | + |
| 18 | +permissions: |
| 19 | + contents: read |
| 20 | + pull-requests: write |
| 21 | + id-token: write # For AWS OIDC (Nix cache) |
| 22 | + |
| 23 | +concurrency: |
| 24 | + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} |
| 25 | + cancel-in-progress: true |
| 26 | + |
| 27 | +jobs: |
| 28 | + dependency-analysis: |
| 29 | + name: Package Dependency Analysis |
| 30 | + runs-on: blacksmith-4vcpu-ubuntu-2404 |
| 31 | + steps: |
| 32 | + - name: Checkout repository |
| 33 | + uses: supabase/postgres/.github/actions/shared-checkout@HEAD |
| 34 | + |
| 35 | + - name: Install Nix |
| 36 | + uses: ./.github/actions/nix-install-ephemeral |
| 37 | + with: |
| 38 | + push-to-cache: "false" |
| 39 | + env: |
| 40 | + DEV_AWS_ROLE: ${{ secrets.DEV_AWS_ROLE }} |
| 41 | + NIX_SIGN_SECRET_KEY: ${{ secrets.NIX_SIGN_SECRET_KEY }} |
| 42 | + |
| 43 | + - name: Run dependency analysis |
| 44 | + id: dep-analysis |
| 45 | + env: |
| 46 | + GH_TOKEN: ${{ github.token }} |
| 47 | + run: | |
| 48 | + PR_URL="${{ github.event.pull_request.html_url || format('https://github.com/{0}/pull/{1}', github.repository, github.event.inputs.pr_number) }}" |
| 49 | + echo "Analyzing PR: $PR_URL" |
| 50 | + ./ci/postgresql-diff.sh "$PR_URL" |
| 51 | +
|
| 52 | + # Read the generated markdown file |
| 53 | + MARKDOWN_FILE=$(find . -maxdepth 1 -name "postgresql-diff-pr-*.md" -type f | head -1) |
| 54 | + if [ -n "$MARKDOWN_FILE" ]; then |
| 55 | + echo "markdown_file=$MARKDOWN_FILE" >> "$GITHUB_OUTPUT" |
| 56 | + echo "Generated file: $MARKDOWN_FILE" |
| 57 | + else |
| 58 | + echo "Error: No markdown file generated" |
| 59 | + exit 1 |
| 60 | + fi |
| 61 | +
|
| 62 | + - name: Find existing dependency comment |
| 63 | + uses: peter-evans/find-comment@v3 |
| 64 | + id: fc-dep |
| 65 | + if: github.event_name == 'pull_request' |
| 66 | + with: |
| 67 | + issue-number: ${{ github.event.pull_request.number }} |
| 68 | + comment-author: "github-actions[bot]" |
| 69 | + body-includes: "<!-- dependency-diff-analysis -->" |
| 70 | + |
| 71 | + - name: Create or update dependency comment |
| 72 | + uses: peter-evans/create-or-update-comment@v4 |
| 73 | + if: github.event_name == 'pull_request' |
| 74 | + with: |
| 75 | + comment-id: ${{ steps.fc-dep.outputs.comment-id }} |
| 76 | + issue-number: ${{ github.event.pull_request.number }} |
| 77 | + body-path: ${{ steps.dep-analysis.outputs.markdown_file }} |
| 78 | + edit-mode: replace |
| 79 | + |
| 80 | + extension-analysis: |
| 81 | + name: Extension Dependency Analysis |
| 82 | + runs-on: blacksmith-4vcpu-ubuntu-2404 |
| 83 | + steps: |
| 84 | + - name: Checkout repository |
| 85 | + uses: supabase/postgres/.github/actions/shared-checkout@HEAD |
| 86 | + |
| 87 | + - name: Install Nix |
| 88 | + uses: ./.github/actions/nix-install-ephemeral |
| 89 | + with: |
| 90 | + push-to-cache: "false" |
| 91 | + env: |
| 92 | + DEV_AWS_ROLE: ${{ secrets.DEV_AWS_ROLE }} |
| 93 | + NIX_SIGN_SECRET_KEY: ${{ secrets.NIX_SIGN_SECRET_KEY }} |
| 94 | + |
| 95 | + - name: Run extension analysis |
| 96 | + id: ext-analysis |
| 97 | + env: |
| 98 | + GH_TOKEN: ${{ github.token }} |
| 99 | + run: | |
| 100 | + PR_URL="${{ github.event.pull_request.html_url || format('https://github.com/{0}/pull/{1}', github.repository, github.event.inputs.pr_number) }}" |
| 101 | + echo "Analyzing PR: $PR_URL" |
| 102 | + ./ci/extensions-diff.sh "$PR_URL" |
| 103 | +
|
| 104 | + # Read the generated markdown file |
| 105 | + MARKDOWN_FILE=$(find . -maxdepth 1 -name "extensions-diff-pr-*.md" -type f | head -1) |
| 106 | + if [ -n "$MARKDOWN_FILE" ]; then |
| 107 | + echo "markdown_file=$MARKDOWN_FILE" >> "$GITHUB_OUTPUT" |
| 108 | + echo "Generated file: $MARKDOWN_FILE" |
| 109 | + else |
| 110 | + echo "Error: No markdown file generated" |
| 111 | + exit 1 |
| 112 | + fi |
| 113 | +
|
| 114 | + - name: Find existing extension comment |
| 115 | + uses: peter-evans/find-comment@v3 |
| 116 | + id: fc-ext |
| 117 | + if: github.event_name == 'pull_request' |
| 118 | + with: |
| 119 | + issue-number: ${{ github.event.pull_request.number }} |
| 120 | + comment-author: "github-actions[bot]" |
| 121 | + body-includes: "<!-- extension-diff-analysis -->" |
| 122 | + |
| 123 | + - name: Create or update extension comment |
| 124 | + uses: peter-evans/create-or-update-comment@v4 |
| 125 | + if: github.event_name == 'pull_request' |
| 126 | + with: |
| 127 | + comment-id: ${{ steps.fc-ext.outputs.comment-id }} |
| 128 | + issue-number: ${{ github.event.pull_request.number }} |
| 129 | + body-path: ${{ steps.ext-analysis.outputs.markdown_file }} |
| 130 | + edit-mode: replace |
0 commit comments