|
| 1 | +name: Release on CloudFront |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: |
| 5 | + - "master" |
| 6 | + - "dev" |
| 7 | + |
| 8 | +jobs: |
| 9 | + release: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + env: |
| 12 | + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} |
| 13 | + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} |
| 14 | + CI: false |
| 15 | + steps: |
| 16 | + - name: Checkout |
| 17 | + uses: actions/checkout@v3 |
| 18 | + with: |
| 19 | + submodules: true |
| 20 | + |
| 21 | + - uses: actions/setup-node@v2 |
| 22 | + with: |
| 23 | + node-version: 16 |
| 24 | + registry-url: https://npm.pkg.github.com/ |
| 25 | + |
| 26 | + - name: Grant @cocrafts package access |
| 27 | + run: | |
| 28 | + echo "@cocrafts:registry=https://npm.pkg.github.com/" >> .npmrc |
| 29 | + echo "//npm.pkg.github.com/:_authToken=${{ secrets.PACKAGE_TOKEN }}" >> .npmrc |
| 30 | +
|
| 31 | + - name: Set branch name |
| 32 | + id: branch |
| 33 | + run: echo "::set-output name=BRANCH_NAME::${GITHUB_REF##*/}" |
| 34 | + |
| 35 | + - name: Install @metacraft/cli |
| 36 | + run: npm i --location=global @metacraft/cli |
| 37 | + |
| 38 | + - name: Install dependencies |
| 39 | + run: yarn |
| 40 | + |
| 41 | + - name: Generate Terraform script |
| 42 | + run: yarn gen ${GITHUB_REF##*/} |
| 43 | + |
| 44 | + - name: Setup Terraform |
| 45 | + uses: hashicorp/setup-terraform@v1 |
| 46 | + with: |
| 47 | + terraform_wrapper: false |
| 48 | + |
| 49 | + - name: Terraform Init |
| 50 | + id: init |
| 51 | + run: terraform init |
| 52 | + |
| 53 | + - name: Terraform Apply |
| 54 | + run: terraform apply -auto-approve |
| 55 | + |
| 56 | + - name: Extract Terraform output |
| 57 | + run: echo $(terraform output -json) > tf-output.json |
| 58 | + |
| 59 | + - name: Build |
| 60 | + run: metacraft bundle |
| 61 | + |
| 62 | + - uses: shallwefootball/s3-upload-action@master |
| 63 | + with: |
| 64 | + aws_bucket: "metacraft-docs-${{ steps.branch.outputs.BRANCH_NAME }}" |
| 65 | + aws_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }} |
| 66 | + aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} |
| 67 | + source_dir: metacraft |
| 68 | + destination_dir: '' |
| 69 | + |
| 70 | + - name: Invalidate CloudFront cache |
| 71 | + run: yarn invalidate ${GITHUB_REF##*/} |
0 commit comments