diff --git a/.github/actions/deploy/action.yml b/.github/actions/deploy/action.yml index 73926553..c96f060a 100644 --- a/.github/actions/deploy/action.yml +++ b/.github/actions/deploy/action.yml @@ -38,6 +38,7 @@ runs: echo "key_vault_name=$(jq -r '.key_vault_name' $TFVARS)" >> $GITHUB_ENV echo "key_vault_app_secret_name=$(jq -r '.key_vault_app_secret_name' $TFVARS)" >> $GITHUB_ENV echo "key_vault_infra_secret_name=$(jq -r '.key_vault_infra_secret_name' $TFVARS)" >> $GITHUB_ENV + echo "namespace=$(jq -r '.namespace' $TFVARS)" >> $GITHUB_ENV if [ -n "${{ inputs.pr-number }}" ]; then APP_NAME=pr-${{ inputs.pr-number }} @@ -111,3 +112,8 @@ runs: run: | az aks get-credentials -g ${{ env.cluster_rg }} -n ${{ env.cluster_name }} make install-konduit + + - name: Generate example data + shell: bash + if: inputs.environment == 'review' + run: kubectl exec -n ${{ env.namespace }} deployment/check-childrens-barred-list-${APP_NAME} -- /bin/sh -c "cd /app && bundle exec rails example_data:generate" diff --git a/lib/tasks/example_data.rake b/lib/tasks/example_data.rake new file mode 100644 index 00000000..77c93208 --- /dev/null +++ b/lib/tasks/example_data.rake @@ -0,0 +1,20 @@ +namespace :example_data do + desc "Create example data for testing" + task generate: :environment do + if HostingEnvironment.production? + raise "THIS TASK CANNOT BE RUN IN PRODUCTION" + end + + if ChildrensBarredListEntry.any? + puts "Noop as DB already contains data" + exit + end + + # Running `bundle exec rails db:migrate example_data:generate` can sometimes + # use cached column information. This forces rails to reload column + # information before attempting to generate factories + ChildrensBarredListEntry.reset_column_information + + FactoryBot.create(:childrens_barred_list_entry, date_of_birth: Date.new(1980, 1, 1)) + end +end