Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update deployment workflows to use fixed branch references #680

Merged
merged 1 commit into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 1 addition & 34 deletions .github/workflows/deploy-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ on:
workflows: [Release Image (Development)]
branches: [dev]
types: [completed]
workflow_dispatch:
jobs:
deploy-dev:
runs-on: ubuntu-latest
Expand All @@ -16,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
2 changes: 1 addition & 1 deletion .github/workflows/deploy-staging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,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
24 changes: 2 additions & 22 deletions .github/workflows/release-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,11 @@ 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

2 changes: 1 addition & 1 deletion .github/workflows/release-staging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,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
Loading