Skip to content

Merge pull request #211 from jonfairbanks/develop #28

Merge pull request #211 from jonfairbanks/develop

Merge pull request #211 from jonfairbanks/develop #28

name: Create Server Release(s)
on:
push:
branches:
- master
- main
jobs:
build:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./server
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
steps:
- uses: act10ns/slack@v1
with:
status: starting
- name: Check Out Repo
uses: actions/checkout@v2
- name: Update Version File(s)
id: update-versions
run: |
# Bump version
npm version --no-git-tag-version patch
# Get new bumped version
PACKAGE_VERSION=$(cat package.json | grep version | head -1 | awk -F: '{ print $2 }' | sed 's/[",]//g' | tr -d '[[:space:]]')
# Update chart version
sed -r -i "s/(version:[^*]|appVersion:[^*])([[:alnum:].]*)/\1$PACKAGE_VERSION/g" ./chart/Chart.yaml
# Output new version for other steps
echo "::set-output name=version::$PACKAGE_VERSION"
- name: Commit Version Updates
uses: EndBug/add-and-commit@v7.2.1
with:
message: "yo-api v${{ steps.update-versions.outputs.version }}"
push: "origin ${{ github.event.repository.default_branch }} --force"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Set Image Tag(s)
id: tag-images
run: |
if [[ ${{ steps.update-versions.outputs.version }} =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
TAGS="jonfairbanks/yo-api:${{ steps.update-versions.outputs.version }},jonfairbanks/yo-api:latest"
else
TAGS="jonfairbanks/yo-api:latest"
fi
echo "::set-output name=tags::${TAGS}"
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Cache Docker Layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Set up QEMU
id: setup-qemu
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
- name: Build & Push Docker Image
id: docker-build
uses: docker/build-push-action@v2
with:
builder: ${{ steps.buildx.outputs.name }}
context: ./server
platforms: linux/amd64,linux/arm64,linux/arm
file: ./server/Dockerfile
push: true
tags: ${{ steps.tag-images.outputs.tags }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
- name: Push Helm Chart to Github Container Registry
id: push-helm-github
uses: bsord/helm-push@v4
with:
useOCIRegistry: true
registry-url: https://ghcr.io/jonfairbanks/yo-api
username: jonfairbanks
access-token: ${{ secrets.GITHUB_TOKEN }}
force: true
chart-folder: ./server/chart
# - name: Push Helm Chart to DigitalOcean Container Registry
# id: push-helm-digital-ocean
# uses: bsord/helm-push@v4
# with:
# useOCIRegistry: true
# registry-url: https://registry.digitalocean.com/fairbanks-io/yo-api
# username: ${{ secrets.DIGITAL_OCEAN_REGISTRY_TOKEN }}
# access-token: ${{ secrets.DIGITAL_OCEAN_REGISTRY_TOKEN }}
# force: true
# chart-folder: ./server/chart
- name: Initiate Helm sync
id: helm-sync
uses: benc-uk/workflow-dispatch@v1
with:
token: ${{ secrets.PERSONAL_TOKEN }}
repo: jonfairbanks/helm-charts
workflow: Helm repo index
- uses: act10ns/slack@v1
with:
status: ${{ job.status }}
steps: ${{ toJson(steps) }}
if: always()