forked from ietf-tools/datatracker
-
Notifications
You must be signed in to change notification settings - Fork 0
179 lines (154 loc) · 5.09 KB
/
dev-db-nightly.yml
File metadata and controls
179 lines (154 loc) · 5.09 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
# GITHUB ACTIONS - WORKFLOW
# Build the database dev docker image with the latest database dump every night
# so that developers don't have to manually build it themselves.
# DB dump becomes available at around 0700 UTC, so schedule is set to 0800 UTC
# to account for variations.
name: Nightly Dev DB Image
# Controls when the workflow will run
on:
# Run every night
schedule:
- cron: '0 8 * * *'
# Run on db.Dockerfile changes
push:
branches:
- main
paths:
- 'docker/db.Dockerfile'
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
build-mariadb:
name: Build MariaDB Docker Images
runs-on: ubuntu-latest
if: ${{ github.ref == 'refs/heads/main' }}
permissions:
contents: read
packages: write
strategy:
matrix:
include:
- platform: "linux/arm64"
docker: "arm64"
- platform: "linux/amd64"
docker: "x64"
steps:
- uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker Build & Push
uses: docker/build-push-action@v3
with:
context: .
file: docker/db.Dockerfile
platforms: ${{ matrix.platform }}
push: true
tags: ghcr.io/ietf-tools/datatracker-db:latest-${{ matrix.docker }}
combine-mariadb:
name: Create MariaDB Docker Manifests
runs-on: ubuntu-latest
needs: [build-mariadb]
permissions:
packages: write
steps:
- name: Get Current Date as Tag
id: date
run: echo "date=$(date +'%Y%m%d')" >> $GITHUB_OUTPUT
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create and Push Manifests
run: |
echo "Creating the manifests..."
docker manifest create ghcr.io/ietf-tools/datatracker-db:nightly-${{ steps.date.outputs.date }} ghcr.io/ietf-tools/datatracker-db:latest-x64 ghcr.io/ietf-tools/datatracker-db:latest-arm64
docker manifest create ghcr.io/ietf-tools/datatracker-db:latest ghcr.io/ietf-tools/datatracker-db:latest-x64 ghcr.io/ietf-tools/datatracker-db:latest-arm64
echo "Pushing the manifests..."
docker manifest push -p ghcr.io/ietf-tools/datatracker-db:nightly-${{ steps.date.outputs.date }}
docker manifest push -p ghcr.io/ietf-tools/datatracker-db:latest
migrate:
name: Migrate MySQL to PostgreSQL DB
runs-on: ubuntu-latest
container: ghcr.io/ietf-tools/datatracker-app-base:latest
needs: [combine-mariadb]
permissions:
contents: read
packages: write
services:
db:
image: ghcr.io/ietf-tools/datatracker-db:latest
volumes:
- mariadb-data:/var/lib/mysql
env:
MYSQL_ROOT_PASSWORD: ietf
MYSQL_DATABASE: ietf_utf8
MYSQL_USER: django
MYSQL_PASSWORD: RkTkDPFnKpko
pgdb:
image: postgres:14.5
volumes:
- /pgdata:/var/lib/postgresql/data
env:
POSTGRES_PASSWORD: RkTkDPFnKpko
POSTGRES_USER: django
POSTGRES_DB: ietf
POSTGRES_HOST_AUTH_METHOD: trust
steps:
- uses: actions/checkout@v3
with:
ref: 'feat/postgres'
- name: Migrate
run: |
chmod +x ./docker/scripts/db-pg-migrate.sh
sh ./docker/scripts/db-pg-migrate.sh
- name: Upload DB Dump
uses: actions/upload-artifact@v3
with:
name: dump
path: ietf.dump
build:
name: Build PostgreSQL Docker Images
runs-on: ubuntu-latest
needs: [migrate]
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v3
with:
ref: 'feat/postgres'
- name: Download DB Dump
uses: actions/download-artifact@v3
with:
name: dump
- name: Get Current Date as Tag
id: date
run: echo "date=$(date +'%Y%m%d')" >> $GITHUB_OUTPUT
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker Build & Push
uses: docker/build-push-action@v3
with:
context: .
file: docker/db-pg.Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ghcr.io/ietf-tools/datatracker-db-pg:latest,ghcr.io/ietf-tools/datatracker-db-pg:nightly-${{ steps.date.outputs.date }}