diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 4c769ab..d7f0766 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -7,21 +7,21 @@ on: workflow_dispatch: jobs: + dump: + uses: Lysquid/ClubBDManga/.github/workflows/dump.yml@main deploy: runs-on: [self-hosted, linux] environment: Production + env: + DB_NAME: ${{ vars.DB_NAME }} + DB_USER: ${{ vars.DB_USER }} + DB_PASSWORD: ${{ secrets.DB_PASSWORD }} + EMAIL: ${{ vars.EMAIL }} + SITE_URL: ${{ vars.SITE_URL }} + SECRET_KEY: ${{ secrets.SECRET_KEY }} steps: - uses: actions/checkout@v3 - - name: Build, restart docker compose and migrate - run: | - docker compose up --build --detach --remove-orphans - docker exec clubbdmanga-db-1 mariadb-dump -u $DB_USER --password=$DB_PASSWORD $DB_NAME > ~/bdmanga_dump_before.sql - docker compose run app python manage.py migrate - docker exec clubbdmanga-db-1 mariadb-dump -u $DB_USER --password=$DB_PASSWORD $DB_NAME > ~/bdmanga_dump_after.sql - env: - DB_NAME: ${{ vars.DB_NAME }} - DB_USER: ${{ vars.DB_USER }} - DB_PASSWORD: ${{ secrets.DB_PASSWORD }} - EMAIL: ${{ vars.EMAIL }} - SITE_URL: ${{ vars.SITE_URL }} - SECRET_KEY: ${{ secrets.SECRET_KEY }} \ No newline at end of file + - name: Build and restart docker compose + run: docker compose up --build --detach --remove-orphans + - name: Migrate + run: docker compose run app python manage.py migrate \ No newline at end of file diff --git a/.github/workflows/dump.yml b/.github/workflows/dump.yml index 68c9c2a..945805d 100644 --- a/.github/workflows/dump.yml +++ b/.github/workflows/dump.yml @@ -18,4 +18,6 @@ jobs: - name: Make dump directory run: mkdir -p ~/$DB_NAME - name: Dump database - run: docker exec clubbdmanga-db-1 mariadb-dump -u $DB_USER --password=$DB_PASSWORD $DB_NAME > ~/$DB_NAME/$(date +"%Y-%m-%d").sql \ No newline at end of file + run: docker exec clubbdmanga-db-1 mariadb-dump -u $DB_USER --password=$DB_PASSWORD $DB_NAME > ~/$DB_NAME/$(date +"%s").sql + - name: Delete dumps older than 30 days + run: find ~/$DB_NAME -type f -mtime +30 -delete \ No newline at end of file