Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ jobs:
lint:
name: Lint
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./frontend
steps:
- name: Git checkout
uses: actions/checkout@v3
Expand All @@ -15,6 +18,7 @@ jobs:

- uses: actions/setup-node@v4
with:
cache-dependency-path: ./frontend/package-lock.json
node-version: 22.5
cache: 'npm'

Expand Down
99 changes: 62 additions & 37 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,42 +1,67 @@
name: Deploy

on:
push:
branches: [ main ]
workflow_dispatch:
push:
branches: [main]
workflow_dispatch:

env:
NOMAD_VERSION: 1.7.7

jobs:
wait:
name: Wait for tests
runs-on: ubuntu-latest
steps:
- name: Wait for tests
uses: lewagon/wait-on-check-action@v1.3.4
with:
ref: ${{ github.ref }}
check-name: Lint
repo-token: ${{ secrets.GITHUB_TOKEN }}
wait-interval: 10

deploy:
runs-on: ubuntu-latest
needs:
- wait

steps:
- name: Git checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

# See the following link for documentation:
# https://github.com/marketplace/actions/dokku
- name: Push to medusa
uses: dokku/github-action@v1.4.0
with:
ssh_private_key: ${{ secrets.MEDUSA_GLOBAL_DEPLOY_KEY }}
git_remote_url: ssh://dokku@medusa.datasektionen.se/bea
# force might feel risky, but there is no good reason why the server
# should ever not be a mirror of the deploy branch. And the errors we
# could get otherwise would probably be nasty to deal with
git_push_flags: --force
wait:
name: Wait for tests
runs-on: ubuntu-latest
steps:
- name: Wait for tests
uses: lewagon/wait-on-check-action@v1.3.4
with:
ref: ${{ github.ref }}
check-name: Lint
repo-token: ${{ secrets.GITHUB_TOKEN }}
wait-interval: 10
deploy:
runs-on: ubuntu-latest
needs:
- wait

steps:
- name: Git checkout
uses: actions/checkout@v4

- name: Set environment variables
run: |
cat >> "$GITHUB_ENV" <<EOF
latest=ghcr.io/${{ github.repository }}-frontend:latest
current=ghcr.io/${{ github.repository }}-frontend:$(git rev-parse --short ${{ github.sha }})
EOF

- name: Download Nomad
run: |
curl -LO https://releases.hashicorp.com/nomad/${{ env.NOMAD_VERSION }}/nomad_${{ env.NOMAD_VERSION }}_linux_amd64.zip
unzip -d /usr/local/bin nomad_${{ env.NOMAD_VERSION }}_linux_amd64.zip nomad

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to ghcr.io
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v5
with:
push: true
tags: ${{ env.latest }},${{ env.current }}
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Deploy to nomad
env:
NOMAD_ADDR: ${{ vars.NOMAD_ADDR }}
NOMAD_TOKEN: ${{ secrets.NOMAD_TOKEN }}
run: |
nomad run -var=image_tag=${{ env.current }} job.nomad.hcl
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
node_modules
/.pnp
.pnp.js
.yarn/install-state.gz
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion Dockerfile → frontend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ COPY next.config.mjs ./
RUN npm run build

EXPOSE 3000
CMD ["npm", "run", "start"]
CMD ["npm", "run", "start"]
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
46 changes: 46 additions & 0 deletions job.nomad.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
job "bea" {
type = "service"

group "bea" {
network {
port "http-frontend" {
to = 3000
}
}

service {
name = "bea-frontend"
port = "http"
provider = "nomad"
tags = [
"traefik.enable=true",
"traefik.http.routers.bea.rule=Host(`metadorerna.se`)",
"traefik.http.routers.bea.tls.certresolver=default",
]
}

task "bea-frontend" {
driver = "docker"

config {
image = var.image_tag-frontend
ports = ["http"]
}

template {
data = "PORT={{ env \"NOMAD_PORT_http-frontend\" }}"
destination = "local/.env"
env = true
}

resources {
memory = 100
}
}
}
}

variable "image_tag-frontend" {
type = string
default = "ghcr.io/datasektionen/bea-frontend:latest"
}