diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..ec0bd09 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,21 @@ +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "monthly" + groups: + actions-deps: + patterns: + - "*" + - package-ecosystem: "cargo" + directory: "/" + schedule: + interval: "monthly" + groups: + cargo-deps: + patterns: + - "*" + update-types: + - "patch" + - "minor" diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..b70c517 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,77 @@ +name: Deploy +on: + push: + branches: ["main"] + pull_request: + branches: ["main"] + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + test: + name: Build/Test + runs-on: ubuntu-latest + steps: + - name: Check out code into the Go module directory + uses: actions/checkout@v5 + with: + fetch-depth: 0 + + - name: Install nix + uses: DeterminateSystems/nix-installer-action@main + + - name: Setup Nix cache + uses: nix-community/cache-nix-action@main + with: + primary-key: nix-${{ runner.os }}-${{ hashFiles('**/*.nix', '**/flake.lock') }} + restore-prefixes-first-match: nix-${{ runner.os }}- + + - name: Build brewlog + run: | + nix build -L .#brewlog + + - name: Run tests + run: | + nix develop --command cargo test -- --show-output + + deploy: + name: Deploy to Fly.io + runs-on: ubuntu-latest + needs: [test] + steps: + - name: Checkout + uses: actions/checkout@v6 + + - name: Install nix + uses: DeterminateSystems/nix-installer-action@v21 + + - name: Setup Nix cache + uses: nix-community/cache-nix-action@main + with: + primary-key: nix-${{ runner.os }}-${{ hashFiles('**/*.nix', '**/flake.lock') }} + restore-prefixes-first-match: nix-${{ runner.os }}- + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build container + run: | + nix build -L .#jnsgruk-container + + - name: Upload container to ghcr.io + run: | + docker load < result + docker tag "jnsgruk/brewlog:$(git rev-parse --short HEAD)" "ghcr.io/jnsgruk/brewlog:$(git rev-parse --short HEAD)" + docker push "ghcr.io/jnsgruk/brewlog:$(git rev-parse --short HEAD)" + + - name: Deploy site + run: | + nix run nixpkgs#flyctl -- deploy -i "ghcr.io/jnsgruk/brewlog:$(git rev-parse --short HEAD)" + env: + FLY_ACCESS_TOKEN: ${{ secrets.FLY_API_TOKEN }}