Skip to content

Commit

Permalink
feat(cd): use environment variables for pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
fpasquet committed Mar 11, 2024
1 parent c0942cc commit f9b0c93
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 28 deletions.
9 changes: 0 additions & 9 deletions .env

This file was deleted.

9 changes: 9 additions & 0 deletions .env.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
ALGOLIA_APP_ID=algolia-app-id
ALGOLIA_INDEX=index
ALGOLIA_API_INDEXING_KEY=algolia-api-indexing-key

VITE_ALGOLIA_APP_ID=algolia-app-id
VITE_ALGOLIA_INDEX=algolia-index
VITE_ALGOLIA_API_KEY=algolia-api-key
VITE_GTM_ID=gtm-id
VITE_GOOGLE_SITE_VERIFICATION=google-site-verification
27 changes: 8 additions & 19 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,16 @@ jobs:
- name: Sets env vars for dev
if: github.event_name == 'pull_request'
run: |
echo "ENV=dev-${{ github.head_ref }}" >> $GITHUB_ENV
echo "ENV=${{ github.head_ref }}" >> $GITHUB_ENV
echo "ENV_URL=https://${{ vars.AWS_BUCKET_NAME }}/${{ github.head_ref }}" >> $GITHUB_ENV
echo "BASE_URL=/${{ github.head_ref }}/" >> $GITHUB_ENV
echo "ALGOLIA_APP_ID=${{ secrets.ALGOLIA_APP_ID }}" >> $GITHUB_ENV
echo "ALGOLIA_INDEX=${{ secrets.ALGOLIA_INDEX_DEV }}" >> $GITHUB_ENV
echo "ALGOLIA_API_INDEXING_KEY=${{ secrets.ALGOLIA_API_INDEXING_KEY_DEV }}" >> $GITHUB_ENV
echo "ALGOLIA_API_SEARCH_KEY=${{ secrets.ALGOLIA_API_SEARCH_KEY_DEV }}" >> $GITHUB_ENV
echo "GTM_ID=${{ secrets.GTM_ID_DEV }}" >> $GITHUB_ENV
- name: Sets env vars for production
if: github.ref == 'refs/heads/master' && github.event_name == 'push'
run: |
echo "ENV=production" >> $GITHUB_ENV
echo "ENV_URL=https://${{ vars.AWS_BUCKET_NAME }}" >> $GITHUB_ENV
echo "BASE_URL=/" >> $GITHUB_ENV
echo "ALGOLIA_APP_ID=${{ secrets.ALGOLIA_APP_ID }}" >> $GITHUB_ENV
echo "ALGOLIA_INDEX=${{ secrets.ALGOLIA_INDEX_PRODUCTION }}" >> $GITHUB_ENV
echo "ALGOLIA_API_INDEXING_KEY=${{ secrets.ALGOLIA_API_INDEXING_KEY_PRODUCTION }}" >> $GITHUB_ENV
echo "ALGOLIA_API_SEARCH_KEY=${{ secrets.ALGOLIA_API_SEARCH_KEY_PRODUCTION }}" >> $GITHUB_ENV
echo "GTM_ID=${{ secrets.GTM_ID_PRODUCTION }}" >> $GITHUB_ENV
echo "GOOGLE_SITE_VERIFICATION==${{ secrets.GOOGLE_SITE_VERIFICATION }}" >> $GITHUB_ENV
- name: Setup node
uses: actions/setup-node@v3
Expand Down Expand Up @@ -103,10 +92,10 @@ jobs:
env:
NODE_ENV: production
BASE_URL: ${{ env.BASE_URL }}
VITE_ALGOLIA_APP_ID: ${{ env.ALGOLIA_APP_ID }}
VITE_ALGOLIA_API_KEY: ${{ env.ALGOLIA_API_SEARCH_KEY }}
VITE_ALGOLIA_INDEX: ${{ env.ALGOLIA_INDEX }}
VITE_GTM_ID: ${{ env.GTM_ID }}
VITE_ALGOLIA_APP_ID: ${{ secrets.ALGOLIA_APP_ID }}
VITE_ALGOLIA_API_KEY: ${{ secrets.ALGOLIA_API_SEARCH_KEY }}
VITE_ALGOLIA_INDEX: ${{ vars.ALGOLIA_INDEX }}
VITE_GTM_ID: ${{ vars.GTM_ID }}

- name: Install aws cli
id: install-aws-cli
Expand Down Expand Up @@ -136,9 +125,9 @@ jobs:
- name: Indexing on Algolia
run: yarn indexation:algolia
env:
ALGOLIA_APP_ID: ${{ env.ALGOLIA_APP_ID }}
ALGOLIA_API_INDEXING_KEY: ${{ env.ALGOLIA_API_INDEXING_KEY }}
ALGOLIA_INDEX: ${{ env.ALGOLIA_INDEX }}
ALGOLIA_APP_ID: ${{ secrets.ALGOLIA_APP_ID }}
ALGOLIA_API_INDEXING_KEY: ${{ secrets.ALGOLIA_API_INDEXING_KEY }}
ALGOLIA_INDEX: ${{ vars.ALGOLIA_INDEX }}

- name: Update deployment status
uses: bobheadxi/deployments@v1
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@ public/imgs/articles
public/imgs/tutorials
public/imgs/authors
public/feed.xml
.env

0 comments on commit f9b0c93

Please sign in to comment.