2023-08-18 03:22:40 +00:00
|
|
|
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
|
2023-08-18 04:52:30 +00:00
|
|
|
# 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 }}
|
2023-08-18 03:22:40 +00:00
|
|
|
|
|
|
|
deploy:
|
|
|
|
needs: [build]
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
if: github.ref == 'refs/heads/main'
|
|
|
|
env:
|
|
|
|
PROD_DEPLOY_CONFIG_PATH: config/production/deployment.toml
|
2023-08-18 04:52:30 +00:00
|
|
|
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
|
2023-08-18 03:22:40 +00:00
|
|
|
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 }}"
|
2023-08-18 04:52:30 +00:00
|
|
|
- uses: actions/download-artifact@v3
|
|
|
|
with:
|
|
|
|
name: built-site
|
|
|
|
path: public/
|
2023-08-18 03:22:40 +00:00
|
|
|
- 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 \
|
2023-08-18 04:52:30 +00:00
|
|
|
-c 'hugo deploy --invalidateCDN'
|