-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
main: support generate declarative workflows (#333)
Co-authored-by: Giau. Tran Minh <[email protected]> Co-authored-by: Ariel Mashraki <[email protected]>
- Loading branch information
1 parent
6ce8f34
commit 73a3917
Showing
26 changed files
with
1,424 additions
and
457 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,26 @@ | ||
{{- define "header" -}} | ||
name: Atlas | ||
on: | ||
push: | ||
branches: | ||
- {{ .DefaultBranch }} | ||
paths: | ||
- .github/workflows/ci-atlas.yaml | ||
- '{{ .Path }}/*' | ||
pull_request: | ||
paths: | ||
- '{{ .Path }}/*' | ||
{{- end }} | ||
|
||
{{- define "permissions" }} | ||
# Permissions to write comments on the pull request. | ||
permissions: | ||
contents: read | ||
pull-requests: write | ||
jobs: | ||
atlas: | ||
{{- if .CreateDevURL }} | ||
{{- end }} | ||
|
||
{{- define "job-setup" }} | ||
{{- if not .Env.HasDevURL }} | ||
{{- template "services" . }} | ||
{{- end }} | ||
runs-on: ubuntu-latest | ||
env: | ||
GITHUB_TOKEN: {{`${{ github.token }}`}} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- uses: ariga/setup-atlas@v0 | ||
with: | ||
cloud-token: {{`${{ secrets.`}}{{ .SecretName }}{{` }}`}} | ||
- uses: ariga/atlas-action/migrate/lint@v1 | ||
with: | ||
dir: 'file://{{ .Path }}' | ||
{{- with .DirName }} | ||
dir-name: '{{ . }}' | ||
{{- end }} | ||
{{- if .CreateDevURL }} | ||
{{ template "UseServices" . }} | ||
{{- end }} | ||
{{- with .ConfigPath }} | ||
config: 'file://{{ . }}' | ||
{{- end }} | ||
{{- with .Env }} | ||
env: '{{ . }}' | ||
{{- end }} | ||
env: | ||
GITHUB_TOKEN: {{`${{ github.token }}`}} | ||
- uses: ariga/atlas-action/migrate/push@v1 | ||
if: github.ref == 'refs/heads/{{ .DefaultBranch }}' | ||
with: | ||
dir: 'file://{{ .Path }}' | ||
{{- with .DirName }} | ||
dir-name: '{{ . }}' | ||
{{- end }} | ||
{{- if .CreateDevURL }} | ||
{{ template "UseServices" . }} | ||
{{- end }} | ||
{{- with .ConfigPath }} | ||
config: 'file://{{ . }}' | ||
{{- end }} | ||
{{- with .Env }} | ||
env: '{{ . }}' | ||
{{- end }} | ||
{{- end }} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
{{ template "header" . }} | ||
on: | ||
push: | ||
branches: [ {{ .DefaultBranch }} ] | ||
pull_request: | ||
branches: [ {{ .DefaultBranch }} ] | ||
workflow_dispatch: | ||
{{- template "permissions" . }} | ||
jobs: | ||
plan: | ||
if: {{`${{ github.event_name == 'pull_request' }}`}} | ||
{{- if not .Env.HasDevURL }} | ||
{{- template "job-setup" . }} | ||
{{- end }} | ||
- uses: ariga/atlas-action/schema/plan@v1 | ||
with: | ||
{{- if .From }} | ||
from: {{ .From }} | ||
{{- end }} | ||
{{- if not .Env.HasSchemaSrc }} | ||
{{- if .To }} | ||
to: {{ .To }} | ||
{{- end }} | ||
{{- end }} | ||
{{- if not .Env.HasRepoName }} | ||
{{- with .CloudRepo }} | ||
schema-name: {{ . }} | ||
{{- end }} | ||
{{- end }} | ||
{{- if not .Env.HasDevURL }} | ||
{{ template "UseServices" . }} | ||
{{- end }} | ||
{{- with .Env.Path }} | ||
config: 'file://{{ . }}' | ||
{{- end }} | ||
{{- with .Env.Name }} | ||
env: '{{ . }}' | ||
{{- end }} | ||
apply: | ||
if: {{`${{ github.event_name == 'push' && github.ref == 'refs/heads/`}}{{ .DefaultBranch }}{{`' }}`}} | ||
{{- if not .Env.HasDevURL }} | ||
{{- template "job-setup" . }} | ||
{{- end }} | ||
- uses: ariga/atlas-action/schema/plan/approve@v1 | ||
id: plan-approve | ||
with: | ||
{{- if not .Env.HasURL }} | ||
{{- if .From }} | ||
from: {{ .From }} | ||
{{- end }} | ||
{{- end }} | ||
{{- if not .Env.HasSchemaSrc }} | ||
{{- if .To }} | ||
to: {{ .To }} | ||
{{- end }} | ||
{{- end }} | ||
{{- if not .Env.HasDevURL }} | ||
{{ template "UseServices" . }} | ||
{{- end }} | ||
{{- if not .Env.HasRepoName }} | ||
{{- with .CloudRepo }} | ||
schema-name: {{ . }} | ||
{{- end }} | ||
{{- end }} | ||
{{- with .Env.Path }} | ||
config: 'file://{{ . }}' | ||
{{- end }} | ||
{{- with .Env.Name }} | ||
env: '{{ . }}' | ||
{{- end }} | ||
- uses: ariga/atlas-action/schema/push@v1 | ||
with: | ||
{{- 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: {{ . }} | ||
{{- end }} | ||
{{- end }} | ||
{{- with .Env.Path }} | ||
config: 'file://{{ . }}' | ||
{{- end }} | ||
{{- with .Env.Name }} | ||
env: '{{ . }}' | ||
{{- end }} | ||
{{- if .SetupSchemaApply }} | ||
- uses: ariga/atlas-action/schema/apply@v1 | ||
if: {{`${{ steps.plan-approve.outputs.status == 'APPROVED' }}`}} | ||
with: | ||
{{- if not .Env.HasURL }} | ||
{{- if .From }} | ||
url: {{ .From }} | ||
{{- end }} | ||
{{- end }} | ||
{{- if not .Env.HasSchemaSrc }} | ||
{{- if .To }} | ||
to: {{ .To }} | ||
{{- end }} | ||
{{- end }} | ||
{{- if not .Env.HasDevURL }} | ||
{{ template "UseServices" . }} | ||
{{- end }} | ||
{{- with .Env.Path }} | ||
config: 'file://{{ . }}' | ||
{{- end }} | ||
{{- with .Env.Name }} | ||
env: '{{ . }}' | ||
{{- end }} | ||
plan: {{`${{ steps.plan-approve.outputs.plan }}`}} | ||
{{- end }} |
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
Oops, something went wrong.