TDR Publish Slick Classes #72
This file contains hidden or 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
| name: TDR Publish Slick Classes | |
| on: | |
| workflow_dispatch: | |
| env: | |
| BRANCH_NAME: version-bump-${{ github.run_id }}${{ github.run_attempt }} | |
| jobs: | |
| deploy-db-changes: | |
| runs-on: ubuntu-latest | |
| services: | |
| postgres: | |
| image: postgres:17 | |
| env: | |
| POSTGRES_PASSWORD: password | |
| POSTGRES_USER: tdr | |
| POSTGRES_DB: consignmentapi | |
| options: >- | |
| --health-cmd pg_isready | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| ports: | |
| - 5432:5432 | |
| steps: | |
| - uses: sbt/setup-sbt@234370af1319038bf8dc432f8a7e4b83078a1781 | |
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 | |
| - uses: actions/setup-java@ae2b61dbc685e60e4427b2e8ed4f0135c6ea8597 | |
| with: | |
| java-version: 17 | |
| distribution: 'temurin' | |
| - name: Import GPG key | |
| id: import_gpg | |
| uses: crazy-max/ghaction-import-gpg@e89d40939c28e39f97cf32126055eeae86ba74ec | |
| with: | |
| git_user_signingkey: true | |
| git_commit_gpgsign: true | |
| gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} | |
| passphrase: ${{ secrets.GPG_PASSPHRASE }} | |
| - name: Publish | |
| id: publish | |
| run: | | |
| PGPASSWORD=password psql -U tdr -h localhost -d consignmentapi -f .github/scripts/create-user.sql | |
| git config --global user.email 181243999+tna-da-bot@users.noreply.github.com | |
| git config --global user.name tna-da-bot | |
| git checkout -b $BRANCH_NAME | |
| git push -u origin $BRANCH_NAME | |
| sbt flywayMigrate slickCodegen 'release with-defaults' | |
| env: | |
| SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} | |
| SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} | |
| - name: Release to GitHub | |
| run: gh release create --generate-notes ${{ steps.publish.outputs.latest-tag}} lambda/target/scala-2.13/db-migrations.jar | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.WORKFLOW_PAT }} | |
| - name: Send success message | |
| uses: nationalarchives/tdr-github-actions/.github/actions/slack-send@main | |
| with: | |
| message: "*Database schema* :arrow_up: The database package has been published" | |
| slack-url: ${{ secrets.SLACK_WEBHOOK }} | |
| - name: Upgrade PG Dump | |
| id: upgrade_pg_dump | |
| run: | | |
| sudo apt install curl ca-certificates | |
| sudo install -d /usr/share/postgresql-common/pgdg | |
| sudo curl -o /usr/share/postgresql-common/pgdg/apt.postgresql.org.asc --fail https://www.postgresql.org/media/keys/ACCC4CF8.asc | |
| sudo sh -c 'echo "deb [signed-by=/usr/share/postgresql-common/pgdg/apt.postgresql.org.asc] https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list' | |
| sudo apt update | |
| sudo apt install postgresql-17 -y | |
| - name: Publish new sql file | |
| run: | | |
| PGPASSWORD=password pg_dump -s -d consignmentapi -U tdr -h localhost > src/main/resources/pg_dump.sql | |
| git add src/main/resources/pg_dump.sql | |
| git commit -m 'Add the latest sql script' || true | |
| git push -u origin $BRANCH_NAME | |
| gh pr create --fill --label 'Version bump' | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.WORKFLOW_PAT }} |