Skip to content

Deploy

Deploy #293

Workflow file for this run

name: Deploy
on:
workflow_dispatch:
inputs:
commit-x86_64-linux-failures:
description: Commit X86-64 Linux failures.nix
required: false
default: true
type: boolean
commit-aarch64-linux-failures:
description: Commit Aarch64 Linux failures.nix
required: false
default: true
type: boolean
commit-aarch64-darwin-failures:
description: Commit Aarch64 Darwin failures.nix
required: false
default: true
type: boolean
force:
description: Force deploy (skip sync check)
required: false
default: false
type: boolean
schedule:
- cron: "0 8,16 * * *"
permissions:
contents: write
# requirements for docs:
pages: write
id-token: write
actions: read
# requirement for the workflow building other systems:
pull-requests: write
jobs:
check-sync:
name: Check if deployment is needed
runs-on: ubuntu-latest
outputs:
should_run: ${{ steps.check.outputs.should_run }}
old_sha: ${{ steps.check.outputs.old_sha }}
steps:
- id: check
run: |
if [ "${{ inputs.force }}" = "true" ]; then
echo "should_run=true" >> "$GITHUB_OUTPUT"
exit 0
fi
UNSTABLE_SHA=$(git ls-remote https://github.com/${{ github.repository }} nyxpkgs-unstable | awk '{print $1}')
printf "Current is '%s', deployed is %s\n" '${{ github.sha }}' "$UNSTABLE_SHA"
echo "old_sha=$UNSTABLE_SHA" >> "$GITHUB_OUTPUT"
if [ "$UNSTABLE_SHA" = "${{ github.sha }}" ]; then
echo "should_run=false" >> "$GITHUB_OUTPUT"
else
echo "should_run=true" >> "$GITHUB_OUTPUT"
fi
deploy-build:
name: Build-all x86-64 Linux (to deploy)
needs: check-sync
if: needs.check-sync.outputs.should_run == 'true'
uses: ./.github/workflows/garuda-build-all-x86_64-linux.yml
secrets: inherit
with:
commit-failures: ${{ inputs.commit-x86_64-linux-failures || false }}
pin: "missing"
deploy-push:
name: Push to nyxpkgs-unstable
needs: deploy-build
if: needs.deploy-build.outputs.built == 'true'
runs-on: ubuntu-latest
timeout-minutes: 20
outputs:
pushed: ${{ steps.push.outcome == 'success' }}
steps:
# Checkout the main branch
- name: Checkout
uses: actions/checkout@v7
with:
fetch-tags: true
- name: Update nyxpkgs-unstable
id: push
run: |
git push origin HEAD:nyxpkgs-unstable --force
notify-socials-deployment:
name: Notify Socials Deployment
needs: [check-sync, deploy-push]
if: needs.deploy-push.outputs.pushed == 'true'
continue-on-error: true
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Collect newly deployed commits
id: collect_new_commits
run: |
COMMITS=$(git log --pretty=format:"- %s" ${{ needs.check-sync.outputs.old_sha }}..HEAD || echo "- Multiple updates")
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
echo "commits<<$EOF" >> "$GITHUB_OUTPUT"
echo "$COMMITS" >> "$GITHUB_OUTPUT"
echo "$EOF" >> "$GITHUB_OUTPUT"
- name: Send Telegram Message
uses: appleboy/telegram-action@master
with:
to: ${{ secrets.TELEGRAM_TO }}
token: ${{ secrets.TELEGRAM_TOKEN }}
message: |
New update deployed!
New commits:
${{ steps.collect_new_commits.outputs.commits }}
- name: Send Matrix Notification
run: |
jq -n --arg commits "$COMMITS" '{"msgtype": "m.notice", "body": "New update deployed!\n\nNew commits:\n\($commits)"}' | \
curl --fail -sS -X PUT -H "Content-Type: application/json" \
"https://${{ secrets.MATRIX_SERVER }}/_matrix/client/v3/rooms/${{ secrets.MATRIX_TO }}/send/m.room.message/${TXN_ID}?access_token=${{ secrets.MATRIX_TOKEN }}" \
-d @-
env:
TXN_ID: ${{ github.run_id }}-${{ github.job }}
COMMITS: ${{ steps.collect_new_commits.outputs.commits }}
deploy-docs:
needs: deploy-push
uses: ./.github/workflows/document.yml
if: needs.deploy-push.outputs.pushed == 'true'
flakehub:
needs: deploy-docs
uses: ./.github/workflows/flakehub-publish-rolling.yml
if: needs.deploy-docs.outputs.built == 'true'
deploy-build-aarch64-linux:
needs: deploy-build
uses: ./.github/workflows/build-all-aarch64-linux.yml
if: needs.deploy-build.outputs.built == 'true'
secrets: inherit
with:
commit-failures: ${{ inputs.commit-aarch64-linux-failures || false }}
pin: "missing"
deploy-build-aarch64-darwin:
needs: deploy-build
uses: ./.github/workflows/build-all-aarch64-darwin.yml
if: needs.deploy-build.outputs.built == 'true'
secrets: inherit
with:
commit-failures: ${{ inputs.commit-aarch64-darwin-failures || false }}
pin: "missing"