Skip to content

Commit

Permalink
Merge pull request #1257 from casper-network/cicd-use-github-environment
Browse files Browse the repository at this point in the history
CI/CD: Setup preview deployments
  • Loading branch information
andrzej-casper authored Aug 24, 2023
2 parents b863e92 + 4e37da4 commit 6a0ef8a
Showing 1 changed file with 40 additions and 3 deletions.
43 changes: 40 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
node-version: ${{ env.selected_node_version }}
cache: yarn

- name: Template credentials
- name: Template credentials - production
if: github.ref == 'refs/heads/dev'
uses: cuchi/jinja2-action@1149b92d9ea6db61d7f71c22e3d5028d8065f140
with:
Expand All @@ -62,6 +62,19 @@ jobs:
ALGOLIA_SITE_INDEX_NAME: ${{ vars.ALGOLIA_SITE_INDEX_NAME }}
BASE_URL: ${{ vars.BASE_URL }}

- name: Template credentials - preview
if: github.event_name == 'pull_request'
uses: cuchi/jinja2-action@1149b92d9ea6db61d7f71c22e3d5028d8065f140
with:
template: .github/templates/.env.production.j2
output_file: .env.production
env:
DIRECTUS_URL: ${{ secrets.PREVIEW_DIRECTUS_URL }}
DIRECTUS_GRAPHQL_URL: ${{ secrets.PREVIEW_DIRECTUS_GRAPHQL_URL }}
DIRECTUS_TOKEN: ${{ secrets.PREVIEW_DIRECTUS_TOKEN }}
SITE_URL: ${{ vars.SITE_URL }}
BASE_URL: ${{ vars.BASE_URL }}

- name: Yarn install
run: |
yarn install
Expand Down Expand Up @@ -148,6 +161,32 @@ jobs:
curl --fail http://127.0.0.1:4000/concepts/serialization-standard/
working-directory: ./docs

deploy-preview:
if: github.event_name == 'pull_request'
needs: [build]
runs-on: ubuntu-latest

steps:
- uses: actions/download-artifact@master
with:
name: gh-pages-depl-payload
path: ./docs

- name: Deploy to Netlify
uses: nwtgck/[email protected]
with:
publish-dir: 'docs'
production-deploy: false
github-token: ${{ secrets.GITHUB_TOKEN }}
deploy-message: ${{ github.event.pull_request.title }}
enable-pull-request-comment: true
enable-commit-comment: false
enable-github-deployment: false
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.PREVIEW_NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.PREVIEW_NETLIFY_SITE_ID }}
timeout-minutes: 1

deploy-prod:
if: ${{ github.ref == 'refs/heads/dev' && github.repository == 'casper-network/docs' }}
needs: [backup, system-tests-predeployment]
Expand Down Expand Up @@ -203,5 +242,3 @@ jobs:
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs


0 comments on commit 6a0ef8a

Please sign in to comment.