DB Restore for staging and prod #3
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
name: DB Restore for staging and prod | |
on: | |
workflow_dispatch: | |
inputs: | |
restoreSourceFile: | |
type: string | |
description: | | |
The restoreSourceFile of the backup in the bucket to restore, e.g. | |
ecamp3-staging/2023-07-17-12-55-33-ecamp3-staging.sql.gz.gpg | |
required: true | |
default: latest | |
branch: | |
type: string | |
description: | | |
Are you really sure that you want to delete the data of this deployment | |
and restore the database with the given backup file? | |
Repeat the branch name to confirm. (e.g. staging or prod) | |
required: true | |
jobs: | |
check-parameters: | |
name: Check the given parameters | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check if branch string matches branch | |
run: | | |
if [ "${{ inputs.branch }}" != "${{ github.ref_name }}" ]; then | |
echo "the given branch name is: ${{ inputs.branch }}" | |
echo "but the workflow ran on ${{ github.ref_name }}" | |
echo "thus exiting because they are not equal." | |
exit 1 | |
fi | |
build-and-push: | |
name: Build and push docker images | |
needs: check-parameters | |
uses: ./.github/workflows/reusable-build-and-push.yml | |
with: | |
tag: ${{ github.ref_name }} | |
secrets: | |
DOCKER_HUB_USERNAME: ${{ vars.DOCKER_HUB_USERNAME }} | |
DOCKER_HUB_PASSWORD: ${{ secrets.DOCKER_HUB_PASSWORD }} | |
upgrade-or-install-deployment: | |
name: Upgrade or install deployment | |
needs: build-and-push | |
uses: ./.github/workflows/reusable-stage-prod-deployment.yml | |
with: | |
restoreSourceFile: ${{ inputs.restoreSourceFile }} | |
secrets: inherit |