Skip to content

Commit

Permalink
chore: re-order push, should come after approve to prevent changi…
Browse files Browse the repository at this point in the history
…ng the states
  • Loading branch information
luantranminh committed Sep 29, 2024
1 parent d8381ef commit 22e9a18
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 30 deletions.
29 changes: 18 additions & 11 deletions gen/declarative.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ jobs:
{{- if .From }}
from: {{ .From }}
{{- end }}
{{- if not .Env.HasSchemaSrc }}
{{- if .To }}
to: {{ .To }}
{{- end }}
{{- end }}
{{- if not .Env.HasRepoName }}
{{- with .CloudRepo }}
schema-name: {{ . }}
Expand All @@ -39,17 +41,22 @@ jobs:
{{- if not .Env.HasDevURL }}
{{- template "job-setup" . }}
{{- end }}
- uses: ariga/atlas-action/schema/push@v1
id: schema-push
- uses: ariga/atlas-action/schema/plan/approve@v1
id: plan-approve
with:
{{- if not .Env.HasDevURL }}
{{ template "UseServices" . }}
{{- if not .Env.HasURL }}
{{- if .From }}
from: {{ .From }}
{{- end }}
{{- end }}
{{- if not .Env.HasSchemaSrc }}
{{- if .To }}
url: {{ .To }}
to: {{ .To }}
{{- end }}
{{- end }}
{{- if not .Env.HasDevURL }}
{{ template "UseServices" . }}
{{- end }}
{{- if not .Env.HasRepoName }}
{{- with .CloudRepo }}
schema-name: {{ . }}
Expand All @@ -61,16 +68,16 @@ jobs:
{{- with .Env.Name }}
env: '{{ . }}'
{{- end }}
- uses: ariga/atlas-action/schema/plan/approve@v1
id: plan-approve
- uses: ariga/atlas-action/schema/push@v1
with:
{{- if .From }}
from: {{ .From }}
{{- end }}
to: {{`${{ steps.schema-push.outputs.url }}`}}
{{- if not .Env.HasDevURL }}
{{ template "UseServices" . }}
{{- end }}
{{- if not .Env.HasSchemaSrc }}
{{- if .To }}
url: {{ .To }}
{{- end }}
{{- end }}
{{- if not .Env.HasRepoName }}
{{- with .CloudRepo }}
schema-name: {{ . }}
Expand Down
13 changes: 6 additions & 7 deletions gen/testdata/declarative/plan_full.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,18 @@ jobs:
- uses: ariga/setup-atlas@v0
with:
cloud-token: ${{ secrets.ATLAS_CLOUD_TOKEN_X1 }}
- uses: ariga/atlas-action/schema/push@v1
id: schema-push
with:
dev-url: 'mysql://root:pass@localhost:3306'
url: atlas://myrepo:v2
schema-name: myrepo
- uses: ariga/atlas-action/schema/plan/approve@v1
id: plan-approve
with:
from: atlas://myrepo:v1
to: ${{ steps.schema-push.outputs.url }}
to: atlas://myrepo:v2
dev-url: 'mysql://root:pass@localhost:3306'
schema-name: myrepo
- uses: ariga/atlas-action/schema/push@v1
with:
dev-url: 'mysql://root:pass@localhost:3306'
url: atlas://myrepo:v2
schema-name: myrepo
- uses: ariga/atlas-action/schema/apply@v1
if: ${{ steps.plan-approve.outputs.status == 'APPROVED' }}
with:
Expand Down
8 changes: 3 additions & 5 deletions gen/testdata/declarative/plan_has_file_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,13 @@ jobs:
env: 'prod'
apply:
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
- uses: ariga/atlas-action/schema/push@v1
id: schema-push
- uses: ariga/atlas-action/schema/plan/approve@v1
id: plan-approve
with:
config: 'file://atlas.hcl'
env: 'prod'
- uses: ariga/atlas-action/schema/plan/approve@v1
id: plan-approve
- uses: ariga/atlas-action/schema/push@v1
with:
to: ${{ steps.schema-push.outputs.url }}
config: 'file://atlas.hcl'
env: 'prod'
- uses: ariga/atlas-action/schema/apply@v1
Expand Down
13 changes: 6 additions & 7 deletions gen/testdata/declarative/plan_no_schema_apply.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,15 @@ jobs:
- uses: ariga/setup-atlas@v0
with:
cloud-token: ${{ secrets.ATLAS_CLOUD_TOKEN_X1 }}
- uses: ariga/atlas-action/schema/push@v1
id: schema-push
with:
dev-url: 'mysql://root:pass@localhost:3306'
url: atlas://myrepo:v2
schema-name: myrepo
- uses: ariga/atlas-action/schema/plan/approve@v1
id: plan-approve
with:
from: atlas://myrepo:v1
to: ${{ steps.schema-push.outputs.url }}
to: atlas://myrepo:v2
dev-url: 'mysql://root:pass@localhost:3306'
schema-name: myrepo
- uses: ariga/atlas-action/schema/push@v1
with:
dev-url: 'mysql://root:pass@localhost:3306'
url: atlas://myrepo:v2
schema-name: myrepo

0 comments on commit 22e9a18

Please sign in to comment.