-
Notifications
You must be signed in to change notification settings - Fork 152
60 lines (51 loc) · 1.69 KB
/
initial-sql-update.yaml
File metadata and controls
60 lines (51 loc) · 1.69 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
name: Update Initial SQL File
on:
schedule:
- cron: "0 0 * * *"
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}-build-env:master
permissions:
contents: write
packages: read
jobs:
update-sql:
runs-on: ubuntu-24.04
steps:
- name: Checkout code
uses: actions/checkout@v5
with:
token: ${{ secrets.LANDER_GH_TOKEN }}
- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Update and Commit
run: |
cd "$GITHUB_WORKSPACE"
docker run --rm \
-v "$GITHUB_WORKSPACE":/work \
-w /work \
ghcr.io/${{ env.IMAGE_NAME }} \
sh -c "
git config --global --add safe.directory /work
useradd ubuntu || true
chown -R ubuntu:ubuntu /work
sudo -H -u ubuntu make install-dependencies
sudo -H -u ubuntu make build
sudo -H -u ubuntu make update-initial-sql
"
# Restore ownership of git repository
sudo chown -R "$(id -u):$(id -g)" "$GITHUB_WORKSPACE"
git config user.name "${{ vars.LANDER_USERNAME }}"
git config user.email "${{ vars.LANDER_EMAIL }}"
git add src/maasserver/testing/initial.maas_test.sql
git status
if git diff --cached --quiet; then
echo "No changes to commit"
exit 0
fi
git commit -m "Update initial SQL"
git push origin HEAD:master