Skip to content

feat env server parse #47

feat env server parse

feat env server parse #47

name: releaser
on:
workflow_dispatch:
push:
branches: [main]
paths: [server/**, .github/workflows/**]
env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}_server
defaults:
run:
working-directory: ./server
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install cosign
if: github.event_name != 'pull_request'
uses: sigstore/cosign-installer@v3
with:
cosign-release: 'v2.1.1'
- name: Setup Docker buildx
uses: docker/setup-buildx-action@v2
# https://github.com/docker/login-action
- name: Login to registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# https://github.com/docker/metadata-action
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
labels: git_commit=${{ github.sha }}
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=ref,enable=true,priority=600,prefix=,suffix=,event=branch
type=ref,enable=true,priority=600,prefix=,suffix=,event=tag
type=ref,enable=true,priority=600,prefix=pr-,suffix=,event=pr
- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: ${{ runner.os }}-buildx-
- uses: docker/build-push-action@v4
with:
context: ./server
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new
# linux/386,linux/amd64,linux/arm/v7,linux/arm64/v8
platforms: linux/amd64
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
swagger:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./server
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Node.js v18.x
uses: actions/setup-node@v3
with:
node-version: 18
- name: Install
run: yarn install
- name: Summon swagger data
run: yarn swagger
- name: deploy
run: |
mkdir swagger && cd swagger
cp ../swagger-output.json swagger.json
if [ "none" != "$cname" ]; then echo "$cname" > CNAME; fi
git config --global user.name "$user_name"
git config --global user.email "$user_email"
git init
git add -A
git commit -m "${{ github.event.head_commit.message }}"
git push -f https://_:"$token"@github.com/a3510377/Elder-Care-App master:assets
env:
token: ${{ secrets.GITHUB_TOKEN }}
user_name: GitHub Action
user_email: action@github.com
cname: none