Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deploy branches to S3 #33

Closed
0xTim opened this issue Mar 4, 2022 · 2 comments · Fixed by #65
Closed

Deploy branches to S3 #33

0xTim opened this issue Mar 4, 2022 · 2 comments · Fixed by #65
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@0xTim
Copy link
Member

0xTim commented Mar 4, 2022

Since the blog is just a static site we should deploy PRs to an S3 bucket. This allows us to see new posts before they are merged, any style changes etc and will work as a test bed for similar functionality in the website.

I have examples of how to do this so it's not a big task

@0xTim 0xTim added the enhancement New feature or request label Mar 4, 2022
@0xTim 0xTim assigned BennyDeBock and unassigned BennyDeBock Mar 4, 2022
@0xTim
Copy link
Member Author

0xTim commented Mar 4, 2022

Here's an example of deploying a branch which can be adapted for the current PR builder

name: Pull Request Deploy

on:
  pull_request:
    branches:
      - main

jobs:
  deploy-pr:
    name: Deploy PR
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3
    - uses: actions/setup-node@v2.5.1
      with:
        node-version: 15.11.0
        cache: npm
    - name: NPM Install
      run: npm install
  build:
    name: Build and Deploy
    runs-on: ubuntu-latest
    env:
      AWS_ACCESS_KEY_ID: ${{ secrets.PR_DEPLOYMENT_AWS_ACCESS_KEY_ID }}
      AWS_SECRET_ACCESS_KEY: ${{ secrets.PR_DEPLOYMENT_AWS_ACCESS_KEY_SECRET }}
      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-node@v2.5.1
        with:
          node-version: 15.11.0
          cache: npm
      - name: NPM Install
        run: npm install
      - name: NPM Build
        run: npm run build
      - name: Deploy S3 Website
        uses: danburtenshaw/s3-website-pr-action@v2
        with:
          bucket-prefix: "vapor-blog-pulls"
          folder-to-copy: "./build"

@0xTim
Copy link
Member Author

0xTim commented Mar 4, 2022

Then we'll need another workflow for cleanups

name: PR - Closed

on:
  pull_request:
    branches:
      - main
      - dev
    types: [closed]

jobs:
  delete-s3:
    name: Delete S3 Website
    runs-on: ubuntu-latest
    env:
      AWS_ACCESS_KEY_ID: ${{ secrets.PR_DEPLOYMENT_AWS_ACCESS_KEY_ID }}
      AWS_SECRET_ACCESS_KEY: ${{ secrets.PR_DEPLOYMENT_AWS_ACCESS_KEY_SECRET }}
      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

    steps:
      - name: Delete Website Bucket
        uses: danburtenshaw/s3-website-pr-action@v2
        with:
          bucket-prefix: "vapor-blog-pulls"

@0xTim 0xTim added good first issue Good for newcomers enhancement New feature or request and removed enhancement New feature or request labels Mar 29, 2022
@0xTim 0xTim linked a pull request Jan 5, 2023 that will close this issue
@0xTim 0xTim closed this as completed in #65 Jan 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants