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

Deploy to dev on merge to main #12

Merged
merged 2 commits into from
Oct 24, 2023
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
40 changes: 40 additions & 0 deletions .github/workflows/generate-tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: "[Job] Generate tag"

on:
workflow_call:
outputs:
tag:
description: "Semver tag of this commit/deployment"
value: ${{ jobs.generate_tag.outputs.tag }}

jobs:
generate_tag:
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.bump_version.outputs.tag }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: "0"
- name: Extract branch name
run: |
if [ "$GITHUB_REF" == "refs/heads/main" ]; then
echo BRANCH_NAME=main >> $GITHUB_ENV
else
branch=${{ github.head_ref }}
branch=${branch//-}
branch=${branch//_}
branch=${branch//\/}
echo BRANCH_NAME=${branch} >> $GITHUB_ENV
fi
- name: Bump version
id: bump_version
uses: anothrNick/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
INITIAL_VERSION: 0.0.0
DEFAULT_BUMP: minor
PRERELEASE: true
PRERELEASE_SUFFIX: ${{ env.BRANCH_NAME }}
RELEASE_BRANCHES: main
WITH_V: true
57 changes: 57 additions & 0 deletions .github/workflows/workflow-main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Main pipeline Workflow

on:
push:
branches:
- main
workflow_dispatch:

defaults:
run:
shell: bash

jobs:
generate-tag:
name: Generate tag
uses: ./.github/workflows/generate-tag.yml

build:
name: Build, Scan & Push Images
needs: [generate-tag]
uses: ./.github/workflows/build-push-images.yml
with:
docker_tag: ${{ needs.generate-tag.outputs.tag }}
secrets:
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

deploy-dev-account:
name: TF Deploy Dev Account
uses: ./.github/workflows/account-deploy.yml
with:
workspace_name: development
secrets:
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

deploy-dev-env:
name: Deploy Development Environment
needs: [build, generate-tag]
uses: ./.github/workflows/env-deploy.yml
with:
workspace_name: development
version_tag: ${{ needs.generate-tag.outputs.tag }}
secrets:
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
github_access_token: ${{ secrets.GITHUB_TOKEN }}

test-dev-env:
name: Test Development Environment
needs: [deploy-dev-env]
uses: ./.github/workflows/env-test.yml
with:
base_url: ${{ needs.deploy-dev-env.outputs.base_url }}
secrets:
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
43 changes: 7 additions & 36 deletions .github/workflows/workflow-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,38 +11,9 @@ defaults:
shell: bash

jobs:
generate-tags:
name: Generate tags
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: "0"
- name: Extract branch name
id: extract_branch
run: |
if [ "$GITHUB_EVENT_NAME" == "push" ]; then
echo BRANCH_NAME=main >> $GITHUB_ENV
else
branch=${{ github.head_ref }}
branch=${branch//-}
branch=${branch//_}
branch=${branch//\/}
echo BRANCH_NAME=${branch} >> $GITHUB_ENV
fi
- name: Bump version
id: bump_version
uses: anothrNick/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
INITIAL_VERSION: 0.0.0
DEFAULT_BUMP: minor
PRERELEASE: true
PRERELEASE_SUFFIX: ${{ env.BRANCH_NAME }}
RELEASE_BRANCHES: main
WITH_V: true
outputs:
docker_tag: ${{ steps.bump_version.outputs.tag }}
generate-tag:
name: Generate tag
uses: ./.github/workflows/generate-tag.yml

generate-environment-workspace-name:
runs-on: ubuntu-latest
Expand All @@ -63,10 +34,10 @@ jobs:

build:
name: Build, Scan & Push Images
needs: [generate-tags]
needs: [generate-tag]
uses: ./.github/workflows/build-push-images.yml
with:
docker_tag: ${{ needs.generate-tags.outputs.docker_tag }}
docker_tag: ${{ needs.generate-tag.outputs.tag }}
secrets:
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
Expand All @@ -82,11 +53,11 @@ jobs:

deploy-pr-env:
name: Deploy PR Environment
needs: [build, generate-tags, generate-environment-workspace-name]
needs: [build, generate-tag, generate-environment-workspace-name]
uses: ./.github/workflows/env-deploy.yml
with:
workspace_name: ${{ needs.generate-environment-workspace-name.outputs.environment_workspace_name }}
version_tag: ${{ needs.generate-tags.outputs.docker_tag }}
version_tag: ${{ needs.generate-tag.outputs.tag }}
secrets:
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
Expand Down