-
-
Notifications
You must be signed in to change notification settings - Fork 3
103 lines (91 loc) · 2.95 KB
/
dev.yml
File metadata and controls
103 lines (91 loc) · 2.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
name: Create dev Docker image
on:
pull_request:
branches: [ main ]
workflow_dispatch:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
DOCKERHUB_USER: codecat
jobs:
tests:
runs-on: ubuntu-latest
services:
mongo:
image: mongo:5
env:
MONGO_INITDB_ROOT_USERNAME: chat
MONGO_INITDB_ROOT_PASSWORD: chat
options: >-
--health-cmd mongo
--health-interval 20s
--health-timeout 10s
--health-retries 5
ports:
- 27017:27017
env:
NODE_ENV: 'test'
DATABASE_URL: 'mongodb://chat:chat@localhost:27017/tests?authSource=admin'
steps:
- uses: actions/checkout@v3
- uses: denoland/setup-deno@v2
with:
deno-version: '2.x'
- run: deno install --allow-scripts
- name: Install frontend dependencies
working-directory: app
run: npm ci
- name: Frontend lint
working-directory: app
run: npm run lint
- run: deno task migrate:tests
- run: deno task check
build-image:
needs: tests
runs-on: ubuntu-latest
permissions: write-all
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Build and push Docker image
id: push
uses: docker/build-push-action@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
context: .
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:build-${{ github.run_number }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
APP_VERSION=build-${{ github.run_number }}
cache-from: type=gha
cache-to: type=gha,mode=max
- run: echo '### Output image' >> $GITHUB_STEP_SUMMARY
- run: echo '```\n${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:build-${{ github.run_number }}\n```\n' >> $GITHUB_STEP_SUMMARY
- uses: actions/github-script@v7
if: github.event_name == 'pull_request'
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: '### Docker image\n\n```\n${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:build-${{ github.run_number }}\n```\n'
})