Merge pull request #49 from cachix/renovate/lock-file-maintenance #231
This file contains 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: Build & Deploy | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
env: | |
CACHE_NAME: cachix-ci-agents | |
jobs: | |
build: | |
strategy: | |
matrix: | |
os: | |
- [ubuntu-latest] | |
- [macos-latest] | |
- [self-hosted, linux, ARM64] | |
runs-on: ${{ matrix.os }} | |
outputs: | |
x86_64-linux: ${{ steps.agent.outputs.x86_64-linux }} | |
aarch64-darwin: ${{ steps.agent.outputs.aarch64-darwin }} | |
aarch64-linux: ${{ steps.agent.outputs.aarch64-linux }} | |
steps: | |
- run: sudo rm -rf /opt& | |
- uses: actions/checkout@v4 | |
- uses: cachix/install-nix-action@v30 | |
- uses: cachix/cachix-action@v15 | |
with: | |
name: ${{ env.CACHE_NAME }} | |
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} | |
- name: Version info | |
run: nix --version | |
- name: Build | |
id: agent | |
run: | | |
system=$(nix eval --raw --impure --expr 'builtins.currentSystem') | |
echo "Building machine for $system" | |
out_path=$(nix build -L --print-out-paths --accept-flake-config) | |
echo "Built $out_path" | |
echo "$system=$out_path" >> $GITHUB_OUTPUT | |
# Wait for all paths to flush to daemon. TODO: fix upstream. | |
sleep 3 | |
deploy: | |
if: github.ref == 'refs/heads/main' | |
needs: build | |
runs-on: [ubuntu-latest] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: cachix/install-nix-action@v30 | |
- uses: cachix/cachix-action@v15 | |
with: | |
name: ${{ env.CACHE_NAME }} | |
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} | |
- name: Deploy | |
env: | |
CACHIX_ACTIVATE_TOKEN: ${{ secrets.CACHIX_ACTIVATE_TOKEN }} | |
run: | | |
cat << EOF >> deploy.json | |
{ | |
"agents": { | |
"linux": "${{ needs.build.outputs.x86_64-linux }}", | |
"macos": "${{ needs.build.outputs.aarch64-darwin }}", | |
"aarch64-linux": "${{ needs.build.outputs.aarch64-linux }}" | |
} | |
} | |
EOF | |
cachix deploy activate deploy.json |