-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add github action for edxapp db dump
- Loading branch information
1 parent
8f3393d
commit 331e2cd
Showing
4 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
version: '3' | ||
services: | ||
mysql: | ||
image: mysql:5.6 | ||
container_name: edx.devstack.mysql | ||
ports: | ||
- '3306:3306' | ||
environment: | ||
MYSQL_ROOT_PASSWORD: "" | ||
MYSQL_ALLOW_EMPTY_PASSWORD: "yes" | ||
volumes: | ||
- ./init:/docker-entrypoint-initdb.d | ||
healthcheck: | ||
test: ["CMD", "mysqladmin" ,"ping", "-h", "localhost"] | ||
timeout: 20s | ||
retries: 10 | ||
edxapp: | ||
image: edxops/edxapp:latest | ||
command: bash -c 'source /edx/app/edxapp/edxapp_env && cd /edx/app/edxapp/edx-platform/ && /edx/app/edxapp/venvs/edxapp/bin/python manage.py lms migrate && /edx/app/edxapp/venvs/edxapp/bin/python manage.py cms migrate' | ||
volumes: | ||
- ../../:/edx/app/edxapp/edx-platform | ||
depends_on: | ||
mysql: | ||
condition: service_healthy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
CREATE DATABASE IF NOT EXISTS `edxapp`; | ||
CREATE DATABASE IF NOT EXISTS `edxapp_csmh`; | ||
GRANT ALL PRIVILEGES ON *.* TO 'edxapp001'@'%' IDENTIFIED BY 'password'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
name: mysqldbdump | ||
on: | ||
push: | ||
branches: | ||
- 'master' | ||
jobs: | ||
mysqldbdump: | ||
name: mysqldbdump | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v2 | ||
- name: Migrate | ||
run: docker-compose -f ./.github/workflows/docker-compose.yml.mysqldbdump up -d | ||
- name: Dump database | ||
run: docker exec -i edx.devstack.mysql mysqldump -u'edxapp001' -p'password' edxapp > edxapp.sql | ||
- name: Commit dump file to repo. | ||
run: ./.github/workflows/mysqldbdump_pr.sh | ||
env: | ||
GH_ACCESS_TOKEN: ${{ secrets.EDX_DEPLOYMENT_GH_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#! /usr/bin/env bash | ||
|
||
export GITHUB_USER='edx-deployment' | ||
export GITHUB_TOKEN=$GH_ACCESS_TOKEN | ||
export GITHUB_EMAIL='[email protected]' | ||
export REPO_NAME='edx-platform' | ||
export DB_NAME='edxapp' | ||
|
||
cd .. | ||
|
||
# install hub | ||
curl -L -o hub.tgz https://github.com/github/hub/releases/download/v2.14.2/hub-linux-amd64-2.14.2.tgz | ||
tar -zxvf hub.tgz | ||
|
||
cd "$REPO_NAME" | ||
|
||
git config --global user.name "${GITHUB_USER}" | ||
git config --global user.email "${GITHUB_EMAIL}" | ||
|
||
obsolete_dump_pr=`../hub-linux*/bin/hub pr list -s open | grep 'github-actions-mysqldbdump' | awk '{print $1}' | sed 's/\#//g'` | ||
if [[ ! -z $obsolete_dump_pr ]]; then | ||
../hub-linux*/bin/hub issue update $obsolete_dump_pr -s closed | ||
fi | ||
|
||
git checkout -b github-actions-mysqldbdump/$GITHUB_SHA | ||
git add "${DB_NAME}".sql | ||
git commit -m "MySQLdbdump" --author "GitHub Actions MySQLdbdump automation <[email protected]>" | ||
git push --set-upstream origin github-actions-mysqldbdump/$GITHUB_SHA | ||
../hub-linux*/bin/hub pull-request -m "${DB_NAME} MySQL database dump" -m "MySQL database dump" -l github-actions-mysqldbdump |