Skip to content
This repository has been archived by the owner on Jun 10, 2024. It is now read-only.

Workflow file for this run

name: Publish Docker image and deploy
on:
release:
types: [published]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '16'
- name: install dependencies
run: npm ci
env:
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
- name: run build
run: npm run build
- uses: actions/upload-artifact@main
with:
name: artifacts
path: dist/
test:
runs-on: ubuntu-latest
needs: build
services:
mongo:
image: mongo
ports:
- 27017:27017
strategy:
matrix:
node-version: [16.x]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- uses: actions/download-artifact@main
with:
name: artifacts
path: dist
- name: install dependencies
run: npm ci
env:
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
- name: test
run: npm test
push_to_registry:
name: Push Docker image to GitHub Packages
needs: test
permissions:
contents: read
packages: write
runs-on: ubuntu-latest
steps:
- name: check out the repo
uses: actions/checkout@v2
- name: get-npm-version
id: package-version
uses: martinbeentjes/npm-get-version-action@master
- name: set up Docker builder
uses: docker/setup-buildx-action@v1
- name: log into GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.CR_PAT }}
- name: push to Github Container Registry
uses: docker/build-push-action@v2
with:
context: .
push: true
build-args: 'github_token=${{ secrets.GITHUB_TOKEN }}'
tags: |
ghcr.io/eddiehubcommunity/api:v${{ steps.package-version.outputs.current-version}}
ghcr.io/eddiehubcommunity/api:latest
# deploy:
# name: deploy to kube cluster
# needs: push_to_registry
# runs-on: ubuntu-latest
# steps:
# - name: check out the repo
# uses: actions/checkout@v2
# - name: get-npm-version
# id: package-version
# uses: martinbeentjes/npm-get-version-action@master
# - uses: Azure/k8s-set-context@v1
# with:
# kubeconfig: ${{ secrets.KUBE_CONFIG }}
# - uses: Azure/[email protected]
# with:
# namespace: 'default'
# manifests: kubernetes/deployment.yaml
# images: 'ghcr.io/eddiehubcommunity/api:v${{ steps.package-version.outputs.current-version}}'
# kubectl-version: 'latest'