Skip to content

Commit

Permalink
added nos workflows & dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
calexandre committed Jun 12, 2024
1 parent a675dcf commit f5cbd01
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 0 deletions.
66 changes: 66 additions & 0 deletions .github/workflows/nosportugal-docker-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Docker build push (GCP)

on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
image-tag:
description: The tag to build the docker image
required: true
type: string

env:
REGISTRY: europe-west1-docker.pkg.dev
IMAGE_NAME: mergeable

jobs:
docker-build-to-gar:
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: 'read'
id-token: 'write'
strategy:
matrix:
env: [staging, prod]
environment: ${{ matrix.env }}
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v2

- uses: docker/metadata-action@v4
id: meta
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
images: |
${{ env.REGISTRY }}/${{ secrets.GCP_REPOSITORY_PATH }}/${{ env.IMAGE_NAME }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha,format=long
type=raw,value=${{ inputs.image-tag }}
flavor: |
latest=auto
- id: auth
uses: google-github-actions/auth@v2
with:
token_format: "access_token"
workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER_ID }}
service_account: ${{ secrets.GCP_SERVICE_ACCOUNT }}
access_token_lifetime: '100s'

- uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: oauth2accesstoken
password: ${{ steps.auth.outputs.access_token }}

- uses: docker/build-push-action@v3
with:
file: nos.Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
13 changes: 13 additions & 0 deletions nos.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM node:lts-alpine

WORKDIR /app

COPY package*.json ./
RUN npm ci --only=production

COPY . .

ENV PORT=${PORT:-3000}
USER 1000:1000

CMD ./node_modules/probot/bin/probot.js run --port $PORT ./index.js

0 comments on commit f5cbd01

Please sign in to comment.