Skip to content

Commit

Permalink
On commit to main, auto-open PR to merge from main to staging (#210)
Browse files Browse the repository at this point in the history
* Add release-process.md and update deploy workflow to run on all versioned tags.
Also, remove value-created-log.md.

* Run deploy workflow on push to main or staging branches.

* Add workflow to open a PR on commit to main. (Includes organize-workflows branch for debugging w/o excessive merging)

* Update release-process.md with PR workflow

* Move PR creation workflow to shared workflow

* Check out repo as first step in pr creation

* Add missing trailing backslash

* remove automerge label

* Quote debugging

* Remove debug feature branch trigger
  • Loading branch information
danielnaab authored Jun 19, 2024
1 parent e5a01c5 commit 74dffac
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 11 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/_create-pr-to-branch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Create pull request to branch

on:
workflow_call:
inputs:
head:
type: string
default: ${{ github.ref_name }}
base:
required: true
type: string

env:
GH_TOKEN: ${{ github.token }}
HEAD: ${{ inputs.head }}
BASE: ${{ inputs.base }}

jobs:
create-pr:
runs-on: ubuntu-latest
outputs:
pr_number: ${{ steps.pr-number.outputs.pull_request_number }}

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Check for existing PR
id: check-pr
run: |
PR=$(gh pr list --base ${BASE} --head ${HEAD} --json number --jq '.[0].number')
echo "::set-output name=pr_exists::$PR"
- name: Create pull request
if: steps.check-pr.outputs.pr_exists == ''
run: |
gh pr create \
--label "autogenerated" \
--base ${BASE} --head ${HEAD} \
--title "Deploy to ${BASE}" \
--body "Automated PR to sync changes from ${HEAD} to ${BASE}."
- name: Get pull request number
id: pr-number
run: echo "pull_request_number=$(gh pr view --json number -q .number || echo "")" >> $GITHUB_OUTPUT
13 changes: 13 additions & 0 deletions .github/workflows/create-pr-to-staging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Create PR from main to staging

on:
push:
branches:
- main

jobs:
create-pr-to-staging:
uses: ./.github/workflows/_create-pr-to-branch.yml
secrets: inherit
with:
base: staging
5 changes: 0 additions & 5 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,9 @@ on:
push:
branches:
- main
tags:
- staging
workflow_dispatch:

env:
TAG_NAME: ${{ github.ref_name }}
REGISTRY: ghcr.io/gsa-tts/atj-platform

jobs:
build-image-doj:
uses: ./.github/workflows/_build-docker-image.yml
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ The project dependencies within the workspace are:
Additional documentation:

- [Architectural Decision Records (ADRs)](./documents/adr/)
- [Non-project contributions](./documents/value-created-log.md)
- [Release process](./documents/release-process.md)

## Overview

Expand Down
14 changes: 14 additions & 0 deletions documents/release-process.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Release process

There are currently two environments:

- `main` (dev, main branch, CI/CD)
- `staging` (manually deployed via a release tag)

## Overview

To promote continuous integration, the 10x Forms Platform uses trunk-based development. In trunk-based development, we collaborate on code in a single, mainline branch.

Deployments are managed by Terraform CDK. On merge to main, the [../.github/workflows/deploy.yml](../.github/workflows/deploy.yml) Github Action workflow builds Docker images for each app in the repository, pushes them to [ghcr.io](https://github.com/orgs/GSA-TTS/packages?repo_name=atj-platform), and deploys to the dev environment (`gsa-tts-10x-atj-dev`).

When commits are made to main, the [../.github/workflows/create-pr-to-staging.yml](../.github/workflows/create-pr-to-staging.yml) workflow creates a PR to deploy to the staging environment, if it doesn't already exist.
5 changes: 0 additions & 5 deletions documents/value-created-log.md

This file was deleted.

0 comments on commit 74dffac

Please sign in to comment.