name: "CI" on: pull_request: push: jobs: lint: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - uses: cachix/install-nix-action@v22 - uses: cachix/cachix-action@v12 with: name: devenv - uses: cachix/cachix-action@v12 with: name: alejandr0angul0-dev authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}" - name: Run pre-commit hooks run: | git fetch origin nix develop --accept-flake-config --impure --command bash -c \ "pre-commit run --from-ref origin/main --to-ref $GITHUB_SHA" build: needs: [lint] runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - uses: cachix/install-nix-action@v22 - uses: cachix/cachix-action@v12 with: name: devenv - uses: cachix/cachix-action@v12 with: name: alejandr0angul0-dev authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}" - run: nix build --accept-flake-config -L # Convoluted upload below is a workaround for #92 # See: # - https://github.com/actions/upload-artifact/issues/92 # - https://github.com/actions/upload-artifact/issues/92#issuecomment-1080347032 - run: echo "UPLOAD_PATH=$(readlink -f result)" >> "$GITHUB_ENV" - uses: actions/upload-artifact@v3 with: name: built-site path: ${{ env.UPLOAD_PATH }} deploy: needs: [build] runs-on: ubuntu-latest if: github.ref == 'refs/heads/main' env: PROD_DEPLOY_CONFIG_PATH: config/production/deployment.toml AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }} HUGO_ENV: production steps: - uses: actions/checkout@v3 - uses: cachix/install-nix-action@v22 - uses: cachix/cachix-action@v12 with: name: devenv - uses: cachix/cachix-action@v12 with: name: alejandr0angul0-dev authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}" - uses: actions/download-artifact@v3 with: name: built-site path: public/ - name: Deploy run: | sed 's~{{S3URL}}~${{ secrets.S3URL }}~g' "${PROD_DEPLOY_CONFIG_PATH}.sample" > "${PROD_DEPLOY_CONFIG_PATH}" sed -i 's~{{CLOUDFRONTDISTRIBUTIONID}}~${{ secrets.CLOUDFRONTDISTRIBUTIONID }}~g' "${PROD_DEPLOY_CONFIG_PATH}" nix develop --accept-flake-config --impure --command bash \ -c 'hugo deploy --invalidateCDN'