Update .github/workflows/build.yaml
This commit is contained in:
174
.github/workflows/build.yaml
vendored
174
.github/workflows/build.yaml
vendored
@@ -1,82 +1,92 @@
|
|||||||
name: Build Website
|
name: Build Website
|
||||||
run-name: Build Website
|
run-name: Build Website
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
name: Build NPM Project
|
name: Build NPM Project
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container: node
|
container: node
|
||||||
steps:
|
steps:
|
||||||
- name: Clone Repository
|
- name: Clone Repository
|
||||||
uses: ztimson/actions/clone@develop
|
uses: ztimson/actions/clone@develop
|
||||||
|
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
run: npm i
|
run: npm i
|
||||||
|
|
||||||
- name: Build Project
|
- name: Build Project
|
||||||
run: npm run build
|
run: npm run build
|
||||||
|
|
||||||
- name: Upload Artifacts
|
- name: Upload Artifacts
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: website
|
name: website
|
||||||
path: dist
|
path: dist
|
||||||
retention-days: 7
|
retention-days: 7
|
||||||
|
|
||||||
tag:
|
tag:
|
||||||
name: Tag Version
|
name: Tag Version
|
||||||
needs: build
|
needs: build
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container: node
|
container: node
|
||||||
steps:
|
steps:
|
||||||
- name: Clone Repository
|
- name: Clone Repository
|
||||||
uses: ztimson/actions/clone@develop
|
uses: ztimson/actions/clone@develop
|
||||||
|
|
||||||
- name: Get Version Number
|
- name: Get Version Number
|
||||||
run: echo "VERSION=$(cat package.json | grep version | grep -Eo ':.+' | grep -Eo '[[:alnum:]\.\/\-]+')" >> $GITHUB_ENV
|
run: echo "VERSION=$(cat package.json | grep version | grep -Eo ':.+' | grep -Eo '[[:alnum:]\.\/\-]+')" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Tag Version
|
- name: Tag Version
|
||||||
uses: ztimson/actions/tag@develop
|
uses: ztimson/actions/tag@develop
|
||||||
with:
|
with:
|
||||||
tag: ${{env.VERSION}}
|
tag: ${{env.VERSION}}
|
||||||
|
|
||||||
container:
|
container:
|
||||||
name: Build Container
|
name: Build Container
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container: docker
|
container: docker
|
||||||
steps:
|
steps:
|
||||||
- name: Build Container
|
- name: Build Container
|
||||||
run: |
|
run: |
|
||||||
git clone -b "${{github.ref_name}}" "$(echo ${{github.server_url}}/${{github.repository}}.git | sed s%://%://${{github.token}}@% )" .
|
git clone -b "${{github.ref_name}}" "$(echo ${{github.server_url}}/${{github.repository}}.git | sed s%://%://${{github.token}}@% )" .
|
||||||
DOCKER_HUB=$([ -n "${{secrets.DOCKER_HUB_USER}}" ] && [ -n "${{secrets.DOCKER_HUB_TOKEN}}" ] && [ -n "${{secrets.DOCKER_HUB_IMAGE}}" ] && echo "true" || echo "false")
|
DOCKER_HUB=$([ -n "${{secrets.DOCKER_HUB_USER}}" ] && [ -n "${{secrets.DOCKER_HUB_TOKEN}}" ] && [ -n "${{secrets.DOCKER_HUB_IMAGE}}" ] && echo "true" || echo "false")
|
||||||
REGISTRY="$(echo "${{github.server_url}}" | sed -E 's|https?://||')"
|
REGISTRY="$(echo "${{github.server_url}}" | sed -E 's|https?://||')"
|
||||||
VERSION=$(cat package.json | grep version | grep -Eo '[0-9][[:alnum:]\.\/\-]+')
|
VERSION=$(cat package.json | grep version | grep -Eo '[0-9][[:alnum:]\.\/\-]+')
|
||||||
|
|
||||||
docker login -u "${{github.repository_owner}}" -p "${{secrets.DEPLOY_TOKEN}}" "$REGISTRY"
|
docker login -u "${{github.repository_owner}}" -p "${{secrets.DEPLOY_TOKEN}}" "$REGISTRY"
|
||||||
if [ "$DOCKER_HUB" = "true" ]; then docker login -u "${{secrets.DOCKER_HUB_USER}}" -p "${{secrets.DOCKER_HUB_TOKEN}}" docker.io; fi
|
if [ "$DOCKER_HUB" = "true" ]; then docker login -u "${{secrets.DOCKER_HUB_USER}}" -p "${{secrets.DOCKER_HUB_TOKEN}}" docker.io; fi
|
||||||
|
|
||||||
docker build -t "$REGISTRY/${{github.repository}}:${{github.ref_name}}" .
|
docker build -t "$REGISTRY/${{github.repository}}:${{github.ref_name}}" .
|
||||||
docker push "$REGISTRY/${{github.repository}}:${{github.ref_name}}"
|
docker push "$REGISTRY/${{github.repository}}:${{github.ref_name}}"
|
||||||
if [ "$DOCKER_HUB" = "true" ]; then
|
if [ "$DOCKER_HUB" = "true" ]; then
|
||||||
docker tag "$REGISTRY/${{github.repository}}:${{github.ref_name}}" "docker.io/${{secrets.DOCKER_HUB_IMAGE}}:${{github.ref_name}}"
|
docker tag "$REGISTRY/${{github.repository}}:${{github.ref_name}}" "docker.io/${{secrets.DOCKER_HUB_IMAGE}}:${{github.ref_name}}"
|
||||||
docker push "docker.io/${{secrets.DOCKER_HUB_IMAGE}}:${{github.ref_name}}"
|
docker push "docker.io/${{secrets.DOCKER_HUB_IMAGE}}:${{github.ref_name}}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "${{github.ref_name}}" = "master" ]; then
|
if [ "${{github.ref_name}}" = "master" ]; then
|
||||||
docker tag "$REGISTRY/${{github.repository}}:${{github.ref_name}}" "$REGISTRY/${{github.repository}}:$VERSION"
|
docker tag "$REGISTRY/${{github.repository}}:${{github.ref_name}}" "$REGISTRY/${{github.repository}}:$VERSION"
|
||||||
docker push "$REGISTRY/${{github.repository}}:$VERSION"
|
docker push "$REGISTRY/${{github.repository}}:$VERSION"
|
||||||
if [ "$DOCKER_HUB" = "true" ]; then
|
if [ "$DOCKER_HUB" = "true" ]; then
|
||||||
docker tag "$REGISTRY/${{github.repository}}:${{github.ref_name}}" "docker.io/${{secrets.DOCKER_HUB_IMAGE}}:$VERSION"
|
docker tag "$REGISTRY/${{github.repository}}:${{github.ref_name}}" "docker.io/${{secrets.DOCKER_HUB_IMAGE}}:$VERSION"
|
||||||
docker push "docker.io/${{secrets.DOCKER_HUB_IMAGE}}:$VERSION"
|
docker push "docker.io/${{secrets.DOCKER_HUB_IMAGE}}:$VERSION"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
docker tag "$REGISTRY/${{github.repository}}:${{github.ref_name}}" "$REGISTRY/${{github.repository}}:latest"
|
docker tag "$REGISTRY/${{github.repository}}:${{github.ref_name}}" "$REGISTRY/${{github.repository}}:latest"
|
||||||
docker push "$REGISTRY/${{github.repository}}:latest"
|
docker push "$REGISTRY/${{github.repository}}:latest"
|
||||||
if [ "$DOCKER_HUB" = "true" ]; then
|
if [ "$DOCKER_HUB" = "true" ]; then
|
||||||
docker tag "$REGISTRY/${{github.repository}}:${{github.ref_name}}" "docker.io/${{secrets.DOCKER_HUB_IMAGE}}:latest"
|
docker tag "$REGISTRY/${{github.repository}}:${{github.ref_name}}" "docker.io/${{secrets.DOCKER_HUB_IMAGE}}:latest"
|
||||||
docker push "docker.io/${{secrets.DOCKER_HUB_IMAGE}}:latest"
|
docker push "docker.io/${{secrets.DOCKER_HUB_IMAGE}}:latest"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
deploy:
|
||||||
|
name: Deploy Container
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container: node
|
||||||
|
needs:
|
||||||
|
- container
|
||||||
|
steps:
|
||||||
|
- name: Deploy
|
||||||
|
run: curl -X POST https://manage.zakscode.com/api/stacks/webhooks/3c8ec201-e8ad-4878-b35a-0f6a99d5f6cf
|
||||||
|
|||||||
Reference in New Issue
Block a user