fix path #30
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Staging Deployment Backend | |
on: | |
push: | |
branches: | |
- master | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
name: checkout backend | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 20 | |
- run: npm ci | |
name: install dependencies | |
working-directory: | |
- run: npm run test | |
name: test with npm | |
working-directory: | |
lint-format: | |
name: lint and format backend | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v4 | |
name: checkout backend | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 20 | |
- run: npm ci | |
name: install dependencies | |
working-directory: | |
- run: | | |
if ! npm run format -- --check .; then | |
echo "Please format the code by running: npm run format" | |
exit 1 | |
fi | |
name: check code formatting | |
working-directory: | |
build-image: | |
runs-on: ubuntu-22.04 | |
needs: [lint-format, test] | |
name: build & push docker image | |
steps: | |
- uses: actions/checkout@v4 | |
name: checkout backend | |
- run: | | |
ls | |
name: debug | |
- name: set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: set up docker buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: docker metadata | |
id: metadata | |
uses: docker/metadata-action@v5 | |
with: | |
images: lnart/dryager-backend | |
tags: | | |
type=raw,value=${{ github.sha }} | |
type=raw,value=latest | |
- name: log in to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_PASSWORD }} | |
- name: build and push | |
uses: docker/build-push-action@v5 | |
with: | |
context: ./ | |
platforms: linux/amd64, linux/arm64 | |
push: true | |
tags: ${{ steps.metadata.outputs.tags }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
push-staging: | |
runs-on: ubuntu-22.04 | |
name: deploy changes on staging | |
needs: build-image | |
steps: | |
- name: set the kubernetes context | |
uses: azure/k8s-set-context@v3 | |
with: | |
method: service-account | |
k8s-url: ${{ secrets.KUBE_SERVER_URL }} | |
k8s-secret: ${{ secrets.KUBE_SERVICE_ACC_SECRET }} | |
- uses: actions/checkout@v4 | |
name: checkout deployments | |
with: | |
submodules: "recursive" | |
# - name: set new kustomize image tag | |
# env: | |
# GITHUB_SHA: ${{ github.sha }} | |
# working-directory: "kubernetes/" | |
# run: | | |
# kustomize edit set image rem-backend-image=notemann27/rememberry-backend:$GITHUB_SHA | |
- name: apply new config to deploy in cluster | |
working-directory: "kubernetes/" | |
env: | |
GITHUB_SHA: ${{ github.sha }} | |
run: | | |
kubectl apply -f ./ |