Files
lunasea/.github/workflows/publish_web.yml
2022-05-11 21:05:47 -04:00

142 lines
4.2 KiB
YAML

name: Publish Web (Docker)
on:
workflow_call:
inputs:
build-number:
required: true
type: string
build-title:
required: true
type: string
flavor:
required: true
type: string
secrets:
NETLIFY_AUTH_TOKEN:
required: true
S3_ACCESS_KEY:
required: true
S3_BUCKET:
required: true
S3_ENDPOINT:
required: true
S3_KEY_ID:
required: true
S3_REGION:
required: true
jobs:
docker:
name: Docker
runs-on: ubuntu-latest
steps:
- name: Setup Environment
uses: JagandeepBrar/LunaSea/.github/actions/prepare_for_deployment@master
with:
channel: docker
ghcr-actor: ${{ github.actor }}
ghcr-token: ${{ github.token }}
- name: Download Docker Image
uses: actions/download-artifact@v3
with:
name: web-docker
path: ${{ github.workspace }}/output
- name: Load Docker Image
run: |
docker load --input ${{ github.workspace}}/output/lunasea-web-docker.tar
docker image ls -a
- name: Deploy to GitHub Container Registry
run: docker image push --all-tags ghcr.io/jagandeepbrar/lunasea
netlify:
name: Netlify
runs-on: ubuntu-latest
steps:
- name: Setup Environment
uses: JagandeepBrar/LunaSea/.github/actions/prepare_for_deployment@master
with:
channel: netlify
- name: Download Web Package
uses: actions/download-artifact@v3
with:
name: web-hosted
path: ${{ github.workspace }}/output
- name: Determine Release Channel
id: channel
uses: actions/github-script@v6
env:
FLAVOR: ${{ inputs.flavor }}
with:
result-encoding: string
script: |
const ref = process.env.FLAVOR || 'edge';
switch (ref) {
case 'beta': return '11ef2676-fc31-41b5-897b-fd21273d87ed';
case 'candidate': return '4636e6a1-17ef-45a2-a2b6-3d1c166fd1df';
case 'stable': return '6634f0b1-323c-4a2f-bd0b-8f1f388673a9';
case 'edge':
default: return '325e197e-55f4-449a-b2bb-6831fe47bf2a';
}
- name: Deploy to Netlify
uses: nwtgck/actions-netlify@v1.2
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ steps.channel.outputs.result }}
with:
publish-dir: ${{ github.workspace}}/output
production-deploy: true
deploy-message: ${{ inputs.build-title }}
s3:
name: S3
runs-on: ubuntu-latest
steps:
- name: Setup Environment
uses: JagandeepBrar/LunaSea/.github/actions/prepare_for_deployment@master
with:
channel: s3
- name: Download Web Archive
uses: actions/download-artifact@v3
with:
name: web-archive
path: ${{ github.workspace }}/output
- name: Upload to S3 Bucket (Build Title)
uses: jakejarvis/s3-sync-action@v0.5.1
with:
args: --acl public-read --follow-symlinks
env:
AWS_ACCESS_KEY_ID: ${{ secrets.S3_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.S3_ACCESS_KEY }}
AWS_S3_BUCKET: ${{ secrets.S3_BUCKET }}
AWS_S3_ENDPOINT: ${{ secrets.S3_ENDPOINT }}
AWS_REGION: ${{ secrets.S3_REGION }}
SOURCE_DIR: ${{ github.workspace }}/output
DEST_DIR: ${{ inputs.build-title }}
- name: Create Version File
working-directory: ${{ github.workspace }}/output
run: echo ${{ inputs.build-number }} > VERSION_WEB.txt
- name: Upload to S3 Bucket (Latest)
uses: jakejarvis/s3-sync-action@v0.5.1
with:
args: --acl public-read --follow-symlinks
env:
AWS_ACCESS_KEY_ID: ${{ secrets.S3_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.S3_ACCESS_KEY }}
AWS_S3_BUCKET: ${{ secrets.S3_BUCKET }}
AWS_S3_ENDPOINT: ${{ secrets.S3_ENDPOINT }}
AWS_REGION: ${{ secrets.S3_REGION }}
SOURCE_DIR: ${{ github.workspace }}/output
DEST_DIR: latest/${{ inputs.flavor }}