Skip to content

feat: add Node v20 to pull request CI (#381) #205

feat: add Node v20 to pull request CI (#381)

feat: add Node v20 to pull request CI (#381) #205

name: Service CI/CD Pipeline to Release and Deploy to Dev Env
on:
push:
branches:
- main
env:
project-directory: ./
jobs:
release:
name: Release
runs-on: ubuntu-latest
if: |
!contains(github.event.head_commit.message, 'skip-ci') &&
github.event_name == 'push' &&
github.repository == "Greenstand/${{ github.event.repository.name }}"
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.event.inputs.git-tag }}
- name: Use Node.js 18.x #semantic-release
uses: actions/setup-node@v1
with:
node-version: '18.x'
- name: npm clean install
run: npm ci
working-directory: ${{ env.project-directory }}
- run: npm i -g semantic-release @semantic-release/{git,exec,changelog}
- run: semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: npm run build
working-directory: ${{ env.project-directory }}
- run: npm prune --production
working-directory: ${{ env.project-directory }}
- name: get-npm-version
id: package-version
uses: martinbeentjes/npm-get-version-action@master
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build snapshot and push on merge
id: docker_build_release
uses: docker/build-push-action@v2
with:
context: ./
file: ./Dockerfile
push: true
tags: greenstand/${{ github.event.repository.name }}:${{ steps.package-version.outputs.current-version }}
- id: export_bumped_version
run: |
export BUMPED_VERSION="${{ steps.package-version.outputs.current-version }}"
echo "::set-output name=bumped_version::${BUMPED_VERSION}"
outputs:
bumped_version: ${{ steps.export_bumped_version.outputs.bumped_version }}
deploy:
name: Deploy to dev env
runs-on: ubuntu-latest
needs: release
if: |
!contains(github.event.head_commit.message, 'skip-ci') &&
github.event_name == 'push' &&
github.repository == "Greenstand/${{ github.event.repository.name }}"
steps:
- uses: actions/checkout@v2
- name: Install kustomize
run: curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash
- name: Run kustomize
run: (cd deployment/base && ../../kustomize edit set image greenstand/${{ github.event.repository.name }}:${{ needs.release.outputs.bumped_version }} )
- name: Install doctl for kubernetes
uses: digitalocean/action-doctl@v2
with:
token: ${{ secrets.DEV_DIGITALOCEAN_TOKEN }}
- name: Save DigitalOcean kubeconfig
run: doctl kubernetes cluster kubeconfig save ${{ secrets.DEV_CLUSTER_NAME }}
#- name: Delete completed migration jobs prior to deployment
# run: kubectl -n ${{ secrets.K8S_NAMESPACE }} delete job --ignore-not-found=true database-migration-job
- name: Update kubernetes resources
run: kustomize build deployment/overlays/development | kubectl apply -n ${{ secrets.K8S_NAMESPACE }} --wait -f -
#- name: Attempt to wait for migration job to complete
# run: kubectl wait -n ${{ secrets.K8S_NAMESPACE }} --for=condition=complete --timeout=45s job/database-migration-job