Skip to content
Draft
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
42 changes: 42 additions & 0 deletions .github/actions/aws-cli/DEPRECATED.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Deprecated

This composite action is deprecated and will be removed after the RFC-001 §7 grace period. It remains functional in the interim and now emits a `::warning::` on every run.

## Why

The action's public contract is "run any AWS CLI command passed as a string". That shape is an arbitrary-command runner dressed up as a helper: historically it also interpolated the input directly into the `run:` body at YAML-expansion time, which allowed callers who passed untrusted strings through `command` to break out of the intended AWS invocation and execute arbitrary shell in a job that had already assumed AWS credentials. The YAML-paste injection has been closed (inputs now travel via `env:`), but the underlying "run whatever the caller passes" shape remains unsafe by design. The right answer is to not have the composite at all.

## Known regression during the grace period

Closing the YAML-paste hole means the action now word-splits `command` through POSIX shell rules only. **Quoted arguments no longer work:** passing `command: '--bucket "my bucket" --key foo'` sends `--bucket`, `"my`, `bucket"`, `--key`, `foo` to the CLI. In the legacy implementation YAML + shell double-interpretation happened to parse the quotes correctly. Callers that rely on quoted arguments should migrate to the recommended replacement **now** rather than wait for the 180-day removal; the replacement (writing your own `run:` step) preserves the usual shell quoting rules.

## Replacement

Assume credentials with [`aws-auth`](../aws-auth) and then write your own explicit `run:` step. Arguments stay as literal shell tokens — no composite wrapping, no indirection, no interpolation surface.

```yaml
- uses: dvsa/.github/.github/actions/aws-auth@v7
with:
aws_role: ${{ vars.AWS_DEPLOY_ROLE }}
aws_account_id: ${{ vars.AWS_ACCOUNT_ID }}
aws_region: ${{ vars.AWS_REGION }}

- name: List S3 buckets
shell: bash
run: aws s3 ls
```

For the narrow cases where the composite was genuinely useful (parameterising a single command across many jobs), either call a purpose-specific reusable workflow in `dvsa/.github/.github/workflows/` (e.g. `update-lambda-function.yaml`) or write a thin service-specific composite that takes structured inputs, not a shell string.

## Timeline

| When | What |
| --------------------------------- | ------------------------------------------------------------------------ |
| This change merges | Every run of `aws-cli` emits a deprecation `::warning::`. |
| T+180 days (per RFC-001 §7) | Follow-up PR removes the action. |

If you maintain a caller still pinned to this action, open an issue on `dvsa/.github` with the label `migration` so we can help you move.

## Related

- `dvsa/appdev-github-actions/.github/actions/assume-and-run-aws` — bundled role-assumption + CLI runner, also deprecated (`DEPRECATED.md` in that repo). Previously named as the replacement pair alongside this action; the actual replacement for both is `aws-auth` + your own `run:`.
53 changes: 40 additions & 13 deletions .github/actions/aws-cli/README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,49 @@
# AWS CLI
Action to provide ability to run AWS CLI command
# aws-cli (deprecated)

#### Prerequisites
Authenticated with AWS Account
**This action is deprecated — see [DEPRECATED.md](DEPRECATED.md).** Prefer writing a plain `run: aws …` step after the [`aws-auth`](../aws-auth) composite. The action remains available during the RFC-001 §7 grace period and emits a `::warning::` on every run.

#### Context
This action allows the workflow to interact with AWS the CLI.
## What it does (for existing callers)

#### Inputs
command (required): Command to be invoked by AWS CLI.
Runs `aws` with the supplied argument string on a runner that already has AWS credentials established (typically by a prior `aws-auth` step).

#### Outputs
N/A
#### Prerequisites

Caller has already configured AWS credentials — this action does **not** assume a role.

#### Inputs

| Input | Required | Description |
| --------- | -------- | --------------------------------------------------------------------------- |
| `command` | yes | Argument string passed to the `aws` CLI. MUST come from a trusted source. |

#### Outputs

None.

#### Legacy usage

#### Usage
```yaml
- name: List S3 Buckets
uses: dvsa/.github/.github/actions/aws-cli@v7
- uses: dvsa/.github/.github/actions/aws-auth@v7
with:
aws_role: ${{ vars.AWS_DEPLOY_ROLE }}
aws_account_id: ${{ vars.AWS_ACCOUNT_ID }}
aws_region: ${{ vars.AWS_REGION }}

- uses: dvsa/.github/.github/actions/aws-cli@v7
with:
command: "s3 ls"
```

#### Recommended replacement

```yaml
- uses: dvsa/.github/.github/actions/aws-auth@v7
with:
aws_role: ${{ vars.AWS_DEPLOY_ROLE }}
aws_account_id: ${{ vars.AWS_ACCOUNT_ID }}
aws_region: ${{ vars.AWS_REGION }}

- name: List S3 buckets
shell: bash
run: aws s3 ls
```
39 changes: 35 additions & 4 deletions .github/actions/aws-cli/action.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,48 @@
name: aws-cli

# DEPRECATED. See DEPRECATED.md in this directory. The replacement is to write
# your own `run: aws …` step after assuming credentials with the `aws-auth`
# composite. This action will be removed after the RFC-001 §7 grace period.
#
# Security notes for the remaining grace-period callers:
# - Inputs are passed via `env:`, not YAML-interpolated into the `run:`
# body, so a value containing shell metacharacters can no longer escape
# out of the step at YAML-expansion time. The step is still an arbitrary
# AWS CLI runner by design; callers MUST NOT pass untrusted strings
# (PR titles, issue bodies, workflow_dispatch inputs sourced from
# untrusted actors, etc.) through `command`.
# - The action no longer runs `actions/checkout`. Callers that need the
# working tree must check out the repo themselves in a prior step.
# - Quoted arguments regress during the grace period: `--bucket "my bucket"`
# word-splits into literal quotes. See DEPRECATED.md. Callers relying on
# quoted args should migrate to the plain `run: aws …` replacement now.

inputs:
command:
type: string
description: Command to be invoked by AWS CLI
description: Arguments to pass to `aws` (deprecated — write your own `run: aws …` step after aws-auth instead).
required: true

runs:
using: 'composite'
steps:
- name: Checkout code
uses: actions/checkout@v7
- name: Deprecation warning
shell: bash
run: |
echo "::warning title=Deprecated action::" \
"dvsa/.github/.github/actions/aws-cli is deprecated. Replace it with a " \
"'run: aws …' step after dvsa/.github/.github/actions/aws-auth. " \
"See .github/actions/aws-cli/DEPRECATED.md."

- name: Invoke AWS CLI command
run: aws ${{ inputs.command }}
shell: bash
env:
AWS_CLI_ARGS: ${{ inputs.command }}
run: |
set -euo pipefail
# Intentional unquoted expansion: callers pass a single string of
# space-separated args, and the historical API relies on shell
# word-splitting to break them apart. This kills the YAML-paste
# injection class (shellcheck SC2086 is expected).
# shellcheck disable=SC2086
aws $AWS_CLI_ARGS
44 changes: 44 additions & 0 deletions .github/actions/check-s3/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# check-s3

Check whether an object (or any object of a given type) exists in an S3 bucket. Emits two outputs: `s3_existence` for a basic `aws s3 ls s3://bucket/path` listing, and `file_existence` for the most recent object whose key **contains** `path` **and ends with** `file_type`. The latest matching object's URL is appended to `GITHUB_STEP_SUMMARY`.

Migrated from `dvsa/appdev-github-actions` (the `check_s3` composite) in Nov 2026; renamed to kebab-case to match sibling composites in this repo.

Requires AWS credentials to be configured on the runner first — use `dvsa/.github/.github/actions/aws-auth@v7` beforehand.

> **Filter semantics.** `s3_existence` is a prefix check (that's how `aws s3 ls` matches). `file_existence` uses JMESPath `contains(Key, …)`, which matches `path` anywhere in the key — not only as a prefix. If two environments share a key segment (e.g. `releases/` and `historic/releases/`) you'll get hits from both. Pass a sufficiently unique `path` or add your own uniqueness suffix.

## Inputs

| Input | Required | Description |
| ----------- | -------- | ------------------------------------------------------------------------- |
| `bucket` | yes | S3 bucket name. |
| `path` | yes | Substring that must appear in the object key (not strictly a prefix). |
| `file_type` | yes | Suffix the object key must end with (e.g. `.zip`). |

## Outputs

| Output | Description |
| ----------------- | ---------------------------------------------------------------- |
| `s3_existence` | `YES` if the prefix returns any listing, `NO` otherwise. |
| `file_existence` | `YES` if the latest matching file was found, `NO` otherwise. |

## Example

```yaml
- uses: dvsa/.github/.github/actions/aws-auth@v7
with:
aws_role: github-actions-read
aws_account_id: ${{ vars.AWS_ACCOUNT_ID }}
aws_region: eu-west-1

- id: check
uses: dvsa/.github/.github/actions/check-s3@v7
with:
bucket: my-bucket
path: releases/v1.2.3/
file_type: .zip

- if: steps.check.outputs.file_existence == 'YES'
run: echo "Found the release artifact."
```
64 changes: 64 additions & 0 deletions .github/actions/check-s3/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: 'Check S3 for Artefacts'
description: 'Check whether a prefix (and optionally a matching object) exists in an S3 bucket.'

inputs:
bucket:
required: true
description: 'The S3 Bucket to check'
path:
required: true
description: 'The path prefix to check in the bucket'
file_type:
required: true
description: 'The file extension/suffix the object must end with (e.g. ".zip")'

outputs:
s3_existence:
description: 'YES if the prefix returns any listing, NO otherwise.'
value: ${{ steps.s3_path.outputs.existence }}
file_existence:
description: 'YES if a matching object was found, NO otherwise.'
value: ${{ steps.s3_file.outputs.existence }}

runs:
using: 'composite'
steps:
- name: Check S3 path exists
id: s3_path
shell: bash
env:
BUCKET: ${{ inputs.bucket }}
PATH_PREFIX: ${{ inputs.path }}
run: |
set -euo pipefail
if aws s3 ls "s3://${BUCKET}/${PATH_PREFIX}" >/dev/null 2>&1; then
echo "existence=YES" >> "$GITHUB_OUTPUT"
else
echo "existence=NO" >> "$GITHUB_OUTPUT"
fi

- name: Check S3 file exists
id: s3_file
shell: bash
env:
BUCKET: ${{ inputs.bucket }}
PATH_PREFIX: ${{ inputs.path }}
FILE_TYPE: ${{ inputs.file_type }}
run: |
set -euo pipefail
# Build the JMESPath filter via jq --arg + tojson so the user-supplied
# strings land inside the query as JSON-quoted literals (backticks in
# JMESPath require JSON values, not raw strings — raw text fails to
# parse). This also neutralises injection into the --query expression.
query=$(jq -nr --arg p "$PATH_PREFIX" --arg t "$FILE_TYPE" \
'"Contents[?contains(Key, `\($p | tojson)`) && ends_with(Key, `\($t | tojson)`)].{Key:Key,LastModified:LastModified}"')
object=$(aws s3api list-objects-v2 \
--bucket "$BUCKET" \
--query "$query" \
--output json | jq -r 'sort_by(.LastModified) | last | .Key // "null"')
if [ "$object" != "null" ] && [ -n "$object" ]; then
echo "existence=YES" >> "$GITHUB_OUTPUT"
echo "Object Found: https://${BUCKET}.s3.eu-west-1.amazonaws.com/${object}" >> "$GITHUB_STEP_SUMMARY"
else
echo "existence=NO" >> "$GITHUB_OUTPUT"
fi
15 changes: 15 additions & 0 deletions .github/actions/notify-teams/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# notify-teams

Send an Adaptive Card notification to a Microsoft Teams Incoming Webhook.

Migrated from `dvsa/appdev-github-actions` (`notify-teams` composite) in Nov 2026 to consolidate DVSA central actions.

## Example

```yaml
- uses: dvsa/.github/.github/actions/notify-teams@v7
with:
webhook_url: ${{ secrets.TEAMS_WEBHOOK_URL }}
title: 'Deploy to prod'
status: 'success'
```
108 changes: 108 additions & 0 deletions .github/actions/notify-teams/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
name: Send Teams Notification
description: 'Send an Adaptive Card notification to a Microsoft Teams channel via an Incoming Webhook.'

inputs:
webhook_url:
description: 'The Teams Incoming Webhook URL. Must be a repository/environment secret.'
required: true
information:
description: 'Extended information rendered in the card (plain text).'
required: false
default: ''
ipa-link:
description: 'Optional URL to the built .ipa file to link from the card.'
required: false
default: ''
qr-link:
description: 'Optional URL to a QR code image for the .ipa download.'
required: false
default: ''

runs:
using: 'composite'
steps:
- name: Microsoft Teams Notification
shell: bash
env:
WEBHOOK_URL: ${{ inputs.webhook_url }}
INFORMATION: ${{ inputs.information }}
IPA_LINK: ${{ inputs.ipa-link }}
QR_LINK: ${{ inputs.qr-link }}
JOB_STATUS: ${{ job.status }}
run: |
set -euo pipefail

case "$JOB_STATUS" in
failure) COLOR=attention ;;
cancelled) COLOR=warning ;;
*) COLOR=good ;;
esac

# Build the Adaptive Card payload with jq --arg so every value is
# JSON-escaped at the string boundary — no interpolation into the
# literal template, no injection via newlines/quotes in inputs.
PAYLOAD=$(jq -n \
--arg status "$JOB_STATUS" \
--arg color "$COLOR" \
--arg information "$INFORMATION" \
--arg repository "$GITHUB_REPOSITORY" \
--arg workflow "$GITHUB_WORKFLOW" \
--arg branch "$GITHUB_REF_NAME" \
--arg actor "$GITHUB_ACTOR" \
--arg run_url "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" \
--arg ipa_link "$IPA_LINK" \
--arg qr_link "$QR_LINK" '
def text($t): { type: "TextBlock", text: $t };
def bold($t): { type: "TextBlock", size: "Large", weight: "Bolder", text: $t };

def openUrl($title; $url):
{ type: "ActionSet",
actions: [ { type: "Action.OpenUrl", title: $title, url: $url } ] };

{
type: "message",
attachments: [{
contentType: "application/vnd.microsoft.card.adaptive",
content: {
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
version: "1.4",
type: "AdaptiveCard",
body: [
{ type: "ColumnSet",
columns: [
{ width: "100px",
items: [ { type: "Image",
url: ("https://raw.githubusercontent.com/Skitionek/notify-microsoft-teams/master/icons/" + $status + ".png"),
size: "stretch" } ] },
{ width: "stretch",
verticalContentAlignment: "center",
items: (
[ bold($workflow) ] +
( if $information != "" then [ bold("Env & Version: " + $information) ] else [] end ) +
[ text("**Repository:** " + $repository),
text("**Branch:** " + $branch),
text("**Who:** " + $actor),
(text("**Status:** " + $status) + { color: $color }) ]
) }
] },
{ type: "ColumnSet",
columns: [
( if $qr_link != "" then
{ width: "100px",
items: [ { type: "Image", url: $qr_link, size: "stretch" } ] }
else empty end ),
{ width: "stretch",
items: (
[ openUrl("View Workflow"; $run_url) ] +
( if $ipa_link != "" then [ openUrl("Get .ipa file"; $ipa_link) ] else [] end )
) }
] }
]
}
}]
}')

curl --fail --silent --show-error \
-H "Content-Type: application/json" \
--data-binary "$PAYLOAD" \
"$WEBHOOK_URL"
Loading