Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/npm_and_yarn/frontend-react/route…
Browse files Browse the repository at this point in the history
…r-2f770ec9bc
  • Loading branch information
jpandersen87 authored Jan 15, 2025
2 parents 0da1dbe + 6e08fd2 commit 1801780
Show file tree
Hide file tree
Showing 36 changed files with 4,082 additions and 2,108 deletions.
21 changes: 21 additions & 0 deletions .github/actions/remote-branch/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Josiah Siegel

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
106 changes: 106 additions & 0 deletions .github/actions/remote-branch/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# Remote Branch Action

## Synopsis

1. Create a branch on a remote repository.
2. [actions/checkout](https://github.com/actions/checkout) determins the active repo.

## Usage

### Single repo
```yml
jobs:
create-branch-action:
name: Create branch
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4

- name: Create branch
uses: CDCgov/prime-reportstream/.github/actions/[email protected]
with:
branch: new-branch
```
### Single alternative repo
```yml
jobs:
create-branch-action:
name: Create branch
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4

- name: Checkout alt repo
uses: actions/checkout@v4
with:
sparse-checkout: .
repository: me/alt-repo
token: ${{ secrets.ALT_REPO_TOKEN }}
path: alt-repo

- name: Create branch on alt repo
uses: CDCgov/prime-reportstream/.github/actions/[email protected]
with:
branch: new-branch-alt-repo
path: alt-repo
```
### Multiple repos
```yml
jobs:
create-branch-action:
name: Create branch
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4

- name: Checkout second repo
uses: actions/checkout@v4
with:
sparse-checkout: .
repository: me/second-repo
token: ${{ secrets.SECONDARY_REPO_TOKEN }}
path: second-repo

- name: Create branch
id: create-branch-action
uses: CDCgov/prime-reportstream/.github/actions/[email protected]
with:
branch: new-branch

- name: Create branch on second repo
id: create-branch-action-second-repo
uses: CDCgov/prime-reportstream/.github/actions/[email protected]
with:
branch: new-branch-second-repo
path: second-repo

- name: Get create branch status
run: echo ${{ steps.create-branch-action.outputs.create-status }}

- name: Get create branch status on second repo
run: echo ${{ steps.create-branch-action-second-repo.outputs.create-status }}
```
## Inputs
```yml
inputs:
branch:
description: Branch name
required: true
path:
description: Relative path under $GITHUB_WORKSPACE to place the repository
required: false
default: '.'
```
## Outputs
```yml
outputs:
create-status:
description: Branch creation status
value: ${{ steps.create-branch.outputs.create_status }}
```
61 changes: 61 additions & 0 deletions .github/actions/remote-branch/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# action.yml
name: Remote Branch Action
description: Create and manage a remote branch
branding:
icon: 'git-branch'
color: 'blue'
inputs:
branch:
description: Branch name
required: true
path:
description: Relative path under $GITHUB_WORKSPACE to place the repository
required: false
default: '.'
outputs:
create-status:
description: Branch creation status
value: ${{ steps.create-branch.outputs.create_status }}

runs:
using: "composite"
steps:

- name: Create branch
id: create-branch
working-directory: ${{ inputs.path }}
shell: bash
run: |
# Assign the arguments to variables
branch_name=${{ inputs.branch }}
# Create a new branch locally
git checkout -b $branch_name
# Check if the branch exists on the remote
check_status=$(git ls-remote --heads origin $branch_name | wc -l)
# Check if the branch does not exist on the remote
if [ $check_status -eq 0 ]; then
# Push the new branch to the remote repository using the token
git push -u origin $branch_name
# Store the status of the push command
status=$?
# Check if the push was successful
if [ $status -eq 0 ]; then
# Print a success message
echo "Branch $branch_name created and pushed"
else
# Print an error message
echo "Branch creation failed with status $status"
status="Branch creation failed with status $status"
fi
else
# Print a message that the branch already exists on the remote
echo "Branch $branch_name already exists"
status="Branch $branch_name already exists"
fi
echo "create_status=$status" >> $GITHUB_OUTPUT
2 changes: 2 additions & 0 deletions .github/actions/terraform-stats/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
terraform/*.git
.github
21 changes: 21 additions & 0 deletions .github/actions/terraform-stats/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 Josiah Siegel

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
107 changes: 107 additions & 0 deletions .github/actions/terraform-stats/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
# Terraform Stats
## Synopsis

Output the following statistics for the Terraform environment:
1. Terraform version
2. Drift count
* "Drift" refers to changes made outside of Terraform and does not necessary match any resources listed for changes.
3. Resource drifts
4. Change count
* "Change" refers to change actions that Terraform plans to use to move from the prior state to a new state.
5. Change percent
* Percentage of changes to total resources.
6. Resource changes

## Usage

```yml
- name: Terraform stats
uses: josiahsiegel/terraform-stats@<latest-version>
id: stats
with:
terraform-directory: ${{ env.tf-dir }}
terraform-version: 1.1.9
- name: Get outputs
run: |
echo "terraform-version: ${{ steps.stats.outputs.terraform-version }}"
echo "drift-count: ${{ steps.stats.outputs.drift-count }}"
echo "resource-drifts: ${{ steps.stats.outputs.resource-drifts }}"
echo "change-count: ${{ steps.stats.outputs.change-count }}"
echo "change-percent: ${{ steps.stats.outputs.change-percent }}"
echo "resource-changes: ${{ steps.stats.outputs.resource-changes }}"
```
## Workflow summary
### :construction: Terraform Stats :construction:
* change-count: 2
* change-percent: 100
* resource-changes:
```json
[
{
"address": "docker_container.nginx",
"changes": [
"create"
]
},
{
"address": "docker_image.nginx",
"changes": [
"create"
]
}
]
```

## Inputs

```yml
inputs:
terraform-directory:
description: Terraform commands will run in this location.
required: true
default: "./terraform"
include-no-op:
description: "\"no-op\" refers to the before and after Terraform changes are identical as a value will only be known after apply."
required: true
default: false
add-args:
description: Pass additional arguments to Terraform plan.
required: true
default: ""
upload-plan:
description: Upload plan file. true or false
required: true
default: false
upload-retention-days:
description: Number of days to keep uploaded plan.
required: true
default: 7
plan-file:
description: Name of plan file.
required: true
default: tf__stats__plan.bin
terraform-version:
description: Specify a specific version of Terraform
required: true
default: latest
```
## Outputs
```yml
outputs:
terraform-version:
description: 'Terraform version'
drift-count:
description: 'Count of drifts'
resource-drifts:
description: 'JSON output of resource drifts'
change-count:
description: 'Count of changes'
change-percent:
description: 'Percentage of changes to total resources'
resource-changes:
description: 'JSON output of resource changes'
```
Loading

0 comments on commit 1801780

Please sign in to comment.