diff --git a/.github/workflows/deploy-dev.yaml b/.github/workflows/deploy-dev.yaml index de729bec..a921f7cb 100644 --- a/.github/workflows/deploy-dev.yaml +++ b/.github/workflows/deploy-dev.yaml @@ -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 @@ -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/vault-action@v2.8.0 diff --git a/.github/workflows/deploy-prod.yaml b/.github/workflows/deploy-prod.yaml index 510f8560..abba4734 100644 --- a/.github/workflows/deploy-prod.yaml +++ b/.github/workflows/deploy-prod.yaml @@ -5,7 +5,6 @@ on: workflows: [Release Image (Production)] branches: [main] types: [completed] - workflow_dispatch: jobs: deploy-prod: runs-on: ubuntu-latest diff --git a/.github/workflows/deploy-staging.yaml b/.github/workflows/deploy-staging.yaml index 294c6244..bdaf4391 100644 --- a/.github/workflows/deploy-staging.yaml +++ b/.github/workflows/deploy-staging.yaml @@ -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 @@ -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/vault-action@v2.8.0 diff --git a/.github/workflows/release-dev.yaml b/.github/workflows/release-dev.yaml index 08e92851..4be5fcf6 100644 --- a/.github/workflows/release-dev.yaml +++ b/.github/workflows/release-dev.yaml @@ -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: @@ -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 + diff --git a/.github/workflows/release-prod.yaml b/.github/workflows/release-prod.yaml index 9a23c171..2e856aba 100644 --- a/.github/workflows/release-prod.yaml +++ b/.github/workflows/release-prod.yaml @@ -1,6 +1,9 @@ --- name: Release Image (Production) -on: workflow_dispatch +on: + push: + branches: + - main jobs: release-docker: name: Release Image diff --git a/.github/workflows/release-staging.yaml b/.github/workflows/release-staging.yaml index 179b3be7..15bd6c92 100644 --- a/.github/workflows/release-staging.yaml +++ b/.github/workflows/release-staging.yaml @@ -1,7 +1,9 @@ --- name: Release Image (Staging) on: - workflow_dispatch: + push: + branches: + - staging jobs: release-docker: name: Release Image @@ -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: