From 97a655bc0c3e18f8c8921b90f14f87f5a07ae837 Mon Sep 17 00:00:00 2001 From: Alejandro Angulo <5242883+alejandro-angulo@users.noreply.github.com> Date: Thu, 17 Aug 2023 21:52:30 -0700 Subject: [PATCH] Fix deployments (#17) --- .github/workflows/ci.yml | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1d0ebd9..ef01623 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,6 +36,15 @@ jobs: 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] @@ -43,6 +52,10 @@ jobs: 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 @@ -53,13 +66,13 @@ jobs: 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 env 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 \ - hugo deploy --invalidateCDN + -c 'hugo deploy --invalidateCDN'