forked from valevo/SABIO
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
57 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
name: Build app and update Docker image | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set variables | ||
id: vars | ||
run: | | ||
echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" | ||
echo "::set-output name=docker_image::ghcr.io/netwerk-digitaal-erfgoed/sabio-backend" | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
with: | ||
# See https://github.com/docker/build-push-action/issues/126. | ||
driver-opts: image=moby/buildkit:master | ||
|
||
- name: Log in to Docker registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.CONTAINER_REGISTRY_TOKEN }} | ||
|
||
- name: Build and push image to registry | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: docker/ | ||
push: true | ||
tags: | | ||
${{ steps.vars.outputs.docker_image }}:${{ steps.vars.outputs.sha_short }} | ||
${{ steps.vars.outputs.docker_image }}:latest | ||
- uses: digitalocean/action-doctl@v2 | ||
with: | ||
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} | ||
|
||
- name: Store DigitalOcean credentials | ||
run: doctl kubernetes cluster kubeconfig save nde | ||
|
||
# See https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#updating-a-deployment | ||
- name: Update deployment | ||
run: | | ||
kubectl set image deployment/sabio-backend app=${{ steps.vars.outputs.docker_image }}:${{ steps.vars.outputs.sha_short }} --record | ||
- name: Verify deployment | ||
run: | | ||
kubectl rollout status deployment/sabio-backend |