Skip to content

Commit

Permalink
Merge pull request #682 from basedosdados/staging
Browse files Browse the repository at this point in the history
Merge Staging em Production
  • Loading branch information
jhonylucas74 authored Sep 19, 2024
2 parents 63e3157 + eb1d69b commit df03fcf
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 66 deletions.
36 changes: 2 additions & 34 deletions .github/workflows/deploy-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ name: Deploy (Development)
on:
workflow_run:
workflows: [Release Image (Development)]
branches: [dev]
types: [completed]
workflow_dispatch:
jobs:
deploy-dev:
runs-on: ubuntu-latest
Expand All @@ -15,42 +15,10 @@ jobs:
name: development
url: https://api.development.basedosdados.org
steps:
- name: Download branch name
uses: actions/github-script@v6
if: ${{ github.event_name == 'workflow_run' }}
with:
script: |
let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.payload.workflow_run.id,
});
let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => {
return artifact.name == "branch"
})[0];
let download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,
archive_format: 'zip',
});
let fs = require('fs');
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/artifact.zip`, Buffer.from(download.data));
- name: Extract branch name
if: ${{ github.event_name == 'workflow_run' }}
run: unzip artifact.zip
- name: Read branch name
id: extract_branch
run: |
if [ ! -f "branch" ]; then
echo "branch=main" >> "$GITHUB_OUTPUT"
else
echo "branch=$(cat branch)" >> "$GITHUB_OUTPUT"
fi
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ steps.extract_branch.outputs.branch }}
ref: dev
- name: Import secrets from Vault
id: import_secrets
uses: hashicorp/[email protected]
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/deploy-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ on:
workflows: [Release Image (Production)]
branches: [main]
types: [completed]
workflow_dispatch:
jobs:
deploy-prod:
runs-on: ubuntu-latest
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/deploy-staging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ name: Deploy (Staging)
on:
workflow_run:
workflows: [Release Image (Staging)]
branches: [main]
branches: [staging]
types: [completed]
workflow_dispatch:
jobs:
deploy-staging:
runs-on: ubuntu-latest
Expand All @@ -19,7 +18,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
with:
ref: main
ref: staging
- name: Import secrets from Vault
id: import_secrets
uses: hashicorp/[email protected]
Expand Down
30 changes: 5 additions & 25 deletions .github/workflows/release-dev.yaml
Original file line number Diff line number Diff line change
@@ -1,29 +1,18 @@
---
name: Release Image (Development)
on:
pull_request:
types: [labeled]
workflow_dispatch:
push:
branches:
- dev
jobs:
release-docker:
name: Release Image
runs-on: ubuntu-latest
if: |
github.event_name == 'workflow_dispatch' ||
contains(github.event.pull_request.labels.*.name, 'preview')
steps:
- name: Select branch
id: select_branch
run: |
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
echo "branch=main" >> $GITHUB_OUTPUT
else
echo "branch=${{ github.event.pull_request.head.ref }}" >> $GITHUB_OUTPUT
fi
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ steps.select_branch.outputs.branch }}
ref: dev
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
Expand All @@ -43,13 +32,4 @@ jobs:
org.opencontainers.image.revision=${{ github.sha }}
build-args: |
BUILDKIT_INLINE_CACHE=1
- name: Save branch name artifact
run: |
mkdir -p ./branch
echo -n ${{ steps.select_branch.outputs.branch }} > ./branch/branch
- name: Upload branch name artifact
uses: actions/upload-artifact@v3
with:
name: branch
path: branch/
retention-days: 1
5 changes: 4 additions & 1 deletion .github/workflows/release-prod.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
---
name: Release Image (Production)
on: workflow_dispatch
on:
push:
branches:
- main
jobs:
release-docker:
name: Release Image
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/release-staging.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
---
name: Release Image (Staging)
on:
workflow_dispatch:
push:
branches:
- staging
jobs:
release-docker:
name: Release Image
Expand All @@ -10,7 +12,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
with:
ref: main
ref: staging
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
Expand Down

0 comments on commit df03fcf

Please sign in to comment.