feat(container): update image ghcr.io/home-operations/gatus-sidecar (0.0.19 ➔ 0.3.5) - autoclosed #69
Workflow file for this run
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
| # yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json | |
| name: Flate | |
| on: | |
| pull_request: | |
| types: [opened, synchronize, reopened, closed] | |
| branches: | |
| - main | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.event.number || github.ref }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: read | |
| env: | |
| DUFS_DOMAIN: dufs.hyde.services | |
| DUFS_USERNAME: flate | |
| jobs: | |
| filter: | |
| name: Flate - Filter | |
| runs-on: ubuntu-latest | |
| outputs: | |
| changed-files: ${{ steps.changed-files.outputs.changed_files }} | |
| steps: | |
| - name: Get Changed Files | |
| id: changed-files | |
| uses: bjw-s-labs/action-changed-files@a9a36fb08ce06db9b02fbd8026cc2c0945eb9841 # v0.6.0 | |
| with: | |
| patterns: kubernetes/**/* | |
| flate: | |
| if: ${{ needs.filter.outputs.changed-files != '[]' && github.event.action != 'closed' }} | |
| needs: filter | |
| name: Flate | |
| runs-on: ubuntu-latest | |
| outputs: | |
| diff: ${{ steps.flate.outputs.diff }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 | |
| with: | |
| fetch-depth: 0 | |
| persist-credentials: false | |
| - name: Setup Mise | |
| uses: jdx/mise-action@dba19683ed58901619b14f395a24841710cb4925 # v4.1.0 | |
| with: | |
| cache: false | |
| tool_versions: | | |
| github:home-operations/flate 0.2.12 | |
| - name: Run flate | |
| id: flate | |
| run: | | |
| flate diff all -p ./kubernetes/flux/cluster --allow-missing-secrets -o html > diff.html | |
| if [ -s diff.html ]; then | |
| echo "diff=true" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "diff=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| - if: ${{ steps.flate.outputs.diff == 'true' }} | |
| name: Load Secrets | |
| id: load-secrets | |
| uses: 1password/load-secrets-action@92467eb28f72e8255933372f1e0707c567ce2259 # v4.0.0 # zizmor: ignore[unpinned-tools] | |
| env: | |
| OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }} | |
| DUFS_PASSWORD: op://K8s/dufs/FLATE_PASSWORD | |
| - if: ${{ steps.flate.outputs.diff == 'true' }} | |
| name: Upload diff to dufs | |
| uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 | |
| env: | |
| DUFS_PASSWORD: ${{ steps.load-secrets.outputs.DUFS_PASSWORD }} | |
| with: | |
| script: | | |
| const fs = require("fs"); | |
| const crypto = require("crypto"); | |
| const pr = context.issue.number; | |
| const dir = `https://${process.env.DUFS_DOMAIN}/flate/`; | |
| const url = `${dir}${pr}.html`; | |
| const auth = "Basic " + Buffer.from(`${process.env.DUFS_USERNAME}:${process.env.DUFS_PASSWORD}`).toString("base64"); | |
| const body = fs.readFileSync("diff.html"); | |
| const localHash = crypto.createHash("sha256").update(body).digest("hex"); | |
| const head = await fetch(`${url}?hash`, { headers: { Authorization: auth } }); | |
| const remoteHash = head.ok ? (await head.text()).trim() : ""; | |
| if (remoteHash === localHash) { | |
| return core.info(`Diff unchanged (sha256 ${localHash}) — skipping upload.`); | |
| } | |
| await fetch(dir, { method: "MKCOL", headers: { Authorization: auth } }); | |
| const res = await fetch(url, { method: "PUT", headers: { Authorization: auth }, body }); | |
| if (!res.ok) return core.setFailed(`PUT ${url} returned HTTP ${res.status}`); | |
| await core.summary.addRaw(`📄 Rendered diff: ${url}`).write(); | |
| comment: | |
| if: ${{ needs.flate.result == 'success' && needs.flate.outputs.diff == 'true' }} | |
| needs: flate | |
| name: Flate - Comment | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Load Secrets | |
| id: load-secrets | |
| uses: 1password/load-secrets-action@92467eb28f72e8255933372f1e0707c567ce2259 # v4.0.0 # zizmor: ignore[unpinned-tools] | |
| env: | |
| OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }} | |
| GITHUB_BOT_APP_CLIENT_ID: op://K8s/github-bot/GITHUB_BOT_APP_CLIENT_ID | |
| GITHUB_BOT_APP_PRIVATE_KEY: op://K8s/github-bot/GITHUB_BOT_APP_PRIVATE_KEY | |
| - name: Generate Token | |
| uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0 | |
| id: app-token | |
| with: | |
| client-id: ${{ steps.load-secrets.outputs.GITHUB_BOT_APP_CLIENT_ID }} | |
| private-key: ${{ steps.load-secrets.outputs.GITHUB_BOT_APP_PRIVATE_KEY }} | |
| permission-pull-requests: write | |
| - name: Add or Update Comment | |
| uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 | |
| with: | |
| github-token: ${{ steps.app-token.outputs.token }} | |
| script: | | |
| const { owner, repo } = context.repo; | |
| const issue_number = context.issue.number; | |
| const marker = `<!-- flate -->`; | |
| const sha = context.payload.pull_request.head.sha; | |
| const shortSha = sha.slice(0, 7); | |
| const commitUrl = `${context.serverUrl}/${owner}/${repo}/commit/${sha}`; | |
| const runUrl = `${context.serverUrl}/${owner}/${repo}/actions/runs/${context.runId}`; | |
| const diffUrl = `https://${process.env.DUFS_DOMAIN}/flate/${issue_number}.html`; | |
| const body = [ | |
| marker, | |
| `### 📄 Flux Diff Preview`, | |
| ``, | |
| `**[View the rendered diff ➔](${diffUrl})** for commit [\`${shortSha}\`](${commitUrl})`, | |
| ``, | |
| `> [!WARNING]`, | |
| `> 🔥 This diff will self destruct after merge.`, | |
| ``, | |
| `<sub>Rendered by [flate](https://github.com/home-operations/flate) · [Workflow run](${runUrl})</sub>`, | |
| ].join("\n"); | |
| const comments = await github.paginate(github.rest.issues.listComments, { | |
| owner, repo, issue_number, per_page: 100, | |
| }); | |
| const existing = comments.find(c => c.body?.includes(marker)); | |
| if (existing) { | |
| await github.rest.issues.updateComment({ owner, repo, comment_id: existing.id, body }); | |
| } else { | |
| await github.rest.issues.createComment({ owner, repo, issue_number, body }); | |
| } | |
| prune: | |
| if: ${{ github.event.action == 'closed' }} | |
| name: Flate - Prune | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Load Secrets | |
| id: load-secrets | |
| uses: 1password/load-secrets-action@92467eb28f72e8255933372f1e0707c567ce2259 # v4.0.0 # zizmor: ignore[unpinned-tools] | |
| env: | |
| OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }} | |
| DUFS_PASSWORD: op://K8s/dufs/FLATE_PASSWORD | |
| - name: Delete diff for closed PR | |
| uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 | |
| env: | |
| DUFS_PASSWORD: ${{ steps.load-secrets.outputs.DUFS_PASSWORD }} | |
| with: | |
| script: | | |
| const pr = context.issue.number; | |
| const url = `https://${process.env.DUFS_DOMAIN}/flate/${pr}.html`; | |
| const auth = "Basic " + Buffer.from(`${process.env.DUFS_USERNAME}:${process.env.DUFS_PASSWORD}`).toString("base64"); | |
| const res = await fetch(url, { method: "DELETE", headers: { Authorization: auth } }); | |
| if (res.ok) core.info(`Deleted ${url}`); | |
| else if (res.status === 404) core.info(`No diff for PR #${pr} — nothing to delete.`); | |
| else core.setFailed(`DELETE ${url} returned HTTP ${res.status}`); | |
| success: | |
| if: ${{ !cancelled() }} | |
| needs: | |
| - flate | |
| - comment | |
| - prune | |
| name: Flate - Success | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Any jobs failed? | |
| if: ${{ contains(needs.*.result, 'failure') }} | |
| run: exit 1 | |
| - name: All jobs passed or skipped? | |
| if: ${{ !(contains(needs.*.result, 'failure')) }} | |
| env: | |
| RESULTS: ${{ toJSON(needs.*.result) }} | |
| run: echo "All jobs passed or skipped" && echo "$RESULTS" |