Install skopeo with nix #3
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 and Deploy | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
jobs: | |
build-deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- uses: nixbuild/nix-quick-install-action@v28 | |
- name: Restore and cache Nix store | |
uses: nix-community/cache-nix-action@v5.1.0 | |
with: | |
# restore and save a cache using this key | |
primary-key: test-nix-${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml', '**/*.nix') }} | |
# if there's no cache hit, restore a cache by this prefix | |
restore-prefixes-first-match: nix-${{ runner.os }}- | |
# collect garbage until Nix store size (in bytes) is at most this number | |
# before trying to save a new cache | |
gc-max-store-size-linux: 1073741824 | |
# do purge caches | |
purge: true | |
# purge all versions of the cache | |
purge-prefixes: cache-${{ runner.os }}- | |
# created more than this number of seconds ago relative to the start of the `Post Restore` phase | |
purge-created: 0 | |
# except the version with the `primary-key`, if it exists | |
purge-primary-key: never | |
- uses: benjlevesque/short-sha@v3.0 | |
id: short-sha | |
with: | |
length: 8 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to private Docker registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ vars.CLOUDFLARE_REGISTRY_URL }} | |
username: ${{ secrets.CLOUDFLARE_REGISTRY_USERNAME }} | |
password: ${{ secrets.CLOUDFLARE_REGISTRY_PASSWORD }} | |
- name: Build and push Docker image | |
run: nix build --extra-experimental-features nix-command --extra-experimental-features flakes --no-filter-syscalls .#docker-image | |
- name: 'Push Docker image to private registry' | |
run: | | |
nix profile install nixpkgs#skopeo | |
skopeo --insecure-policy copy tarball:result docker://${{ vars.CLOUDFLARE_REGISTRY_URL }}/todo-app:${{ env.SHA }} | |
# - name: Deploy | |
# uses: peter-evans/repository-dispatch@v2 | |
# with: | |
# event-type: deploy-todo-app | |
# token: ${{ secrets.FLUX_BOT_TOKEN }} | |
# repository: mbenedettini/hetzner-k3s-cluster | |
# client-payload: '{"sha": "${{ env.SHA }}"}' |