Skip to content

ci: explicit permission and quote user definable input in actions #1522

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

Merged
merged 1 commit into from
Apr 4, 2025
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
12 changes: 6 additions & 6 deletions .github/workflows/ami-release-nix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ on:
- 'ansible/vars.yml'
workflow_dispatch:

permissions:
contents: read
id-token: write

jobs:
prepare:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -41,10 +45,6 @@ jobs:
mcpu: neoverse-n1
runs-on: ${{ matrix.runner }}
timeout-minutes: 150
permissions:
contents: write
packages: write
id-token: write

steps:
- name: Checkout Repo
Expand All @@ -56,7 +56,7 @@ jobs:
if: ${{ github.event_name == 'workflow_dispatch' }}
run: |
SUFFIX=$(sudo nix run nixpkgs#yq -- ".postgres_release[\"postgres${{ matrix.postgres_version }}\"]" ansible/vars.yml | sed -E 's/[0-9\.]+(.*)$/\1/')
if [[ -z $SUFFIX ]] ; then
if [[ -z "$SUFFIX" ]] ; then
echo "Version must include non-numeric characters if built manually."
exit 1
fi
Expand All @@ -67,7 +67,7 @@ jobs:
- name: Generate common-nix.vars.pkr.hcl
run: |
PG_VERSION=$(sudo nix run nixpkgs#yq -- '.postgres_release["postgres'${{ matrix.postgres_version }}'"]' ansible/vars.yml)
PG_VERSION=$(echo $PG_VERSION | tr -d '"') # Remove any surrounding quotes
PG_VERSION=$(echo "$PG_VERSION" | tr -d '"') # Remove any surrounding quotes
echo 'postgres-version = "'$PG_VERSION'"' > common-nix.vars.pkr.hcl
# Ensure there's a newline at the end of the file
echo "" >> common-nix.vars.pkr.hcl
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/check-shellscripts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ on:
pull_request:
workflow_dispatch:

permissions:
contents: read

jobs:
build:
runs-on: ubuntu-latest
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ name: Check merge requirements
on:
pull_request:

permissions:
contents: read

jobs:
check-release-version:
timeout-minutes: 5
Expand Down
10 changes: 9 additions & 1 deletion .github/workflows/dockerhub-release-matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ on:
- ".github/workflows/dockerhub-release-matrix.yml"
- "ansible/vars.yml"
workflow_dispatch:


permissions:
contents: read
id-token: write

jobs:
prepare:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -233,6 +237,10 @@ jobs:
matrix: ${{ steps.combine.outputs.matrix }}
publish:
needs: combine_results
permissions:
contents: read
packages: write
id-token: write
strategy:
matrix: ${{ fromJson(needs.combine_results.outputs.matrix) }}
uses: ./.github/workflows/mirror.yml
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/manual-docker-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ on:
description: 'Optional. Postgres version to publish against, i.e. 15.1.1.78'
required: false

permissions:
id-token: write
contents: read

jobs:
prepare:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -241,6 +245,10 @@ jobs:
outputs:
matrix: ${{ steps.combine.outputs.matrix }}
publish:
permissions:
contents: read
packages: write
id-token: write
needs: combine_results
strategy:
matrix: ${{ fromJson(needs.combine_results.outputs.matrix) }}
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/mirror-postgrest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ on:
- ".github/workflows/mirror-postgrest.yml"
- "common.vars*"

permissions:
contents: read

jobs:
version:
runs-on: ubuntu-latest
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/mirror.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ on:
required: true
type: string

permissions:
contents: read

jobs:
mirror:
runs-on: ubuntu-latest
Expand Down
20 changes: 10 additions & 10 deletions .github/workflows/publish-nix-pgupgrade-bin-flake-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,19 @@ jobs:
id: process_release_version
run: |
VERSION=$(nix run nixpkgs#yq -- '.postgres_release["postgres'${{ matrix.postgres_version }}'"]' ansible/vars.yml)
VERSION=$(echo $VERSION | tr -d '"') # Remove any surrounding quotes
VERSION=$(echo "$VERSION" | tr -d '"') # Remove any surrounding quotes
if [[ "${{ inputs.postgresVersion }}" != "" ]]; then
VERSION=${{ inputs.postgresVersion }}
VERSION="${{ inputs.postgresVersion }}"
fi
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "major_version=$(echo $VERSION | cut -d'.' -f1)" >> "$GITHUB_OUTPUT"

- name: Create a tarball containing the latest nix flake version
working-directory: /tmp/
run: |
mkdir -p ${{ steps.process_release_version.outputs.major_version }}
echo $GITHUB_SHA > ${{ steps.process_release_version.outputs.major_version }}/nix_flake_version
tar -czvf pg_upgrade_bin.tar.gz ${{ steps.process_release_version.outputs.major_version }}
mkdir -p "${{ steps.process_release_version.outputs.major_version }}"
echo "$GITHUB_SHA" > "${{ steps.process_release_version.outputs.major_version }}/nix_flake_version"
tar -czvf pg_upgrade_bin.tar.gz "${{ steps.process_release_version.outputs.major_version }}"

- name: configure aws credentials - staging
uses: aws-actions/configure-aws-credentials@v1
Expand All @@ -66,7 +66,7 @@ jobs:

- name: Upload pg_upgrade scripts to s3 staging
run: |
aws s3 cp /tmp/pg_upgrade_bin.tar.gz s3://${{ secrets.ARTIFACTS_BUCKET }}/upgrades/postgres/supabase-postgres-${{ steps.process_release_version.outputs.version }}/20.04.tar.gz
aws s3 cp /tmp/pg_upgrade_bin.tar.gz "s3://${{ secrets.ARTIFACTS_BUCKET }}/upgrades/postgres/supabase-postgres-${{ steps.process_release_version.outputs.version }}/20.04.tar.gz"

- name: Slack Notification on Failure
if: ${{ failure() }}
Expand Down Expand Up @@ -101,9 +101,9 @@ jobs:
- name: Create a tarball containing the latest nix flake version
working-directory: /tmp/
run: |
mkdir -p ${{ steps.process_release_version.outputs.major_version }}
echo $GITHUB_SHA > ${{ steps.process_release_version.outputs.major_version }}/nix_flake_version
tar -czvf pg_upgrade_bin.tar.gz ${{ steps.process_release_version.outputs.major_version }}
mkdir -p "${{ steps.process_release_version.outputs.major_version }}"
echo "$GITHUB_SHA" > "${{ steps.process_release_version.outputs.major_version }}/nix_flake_version"
tar -czvf pg_upgrade_bin.tar.gz "${{ steps.process_release_version.outputs.major_version }}"

- name: configure aws credentials - prod
uses: aws-actions/configure-aws-credentials@v1
Expand All @@ -113,7 +113,7 @@ jobs:

- name: Upload pg_upgrade scripts to s3 prod
run: |
aws s3 cp /tmp/pg_upgrade_bin.tar.gz s3://${{ secrets.PROD_ARTIFACTS_BUCKET }}/upgrades/postgres/supabase-postgres-${{ steps.process_release_version.outputs.version }}/20.04.tar.gz
aws s3 cp /tmp/pg_upgrade_bin.tar.gz "s3://${{ secrets.PROD_ARTIFACTS_BUCKET }}/upgrades/postgres/supabase-postgres-${{ steps.process_release_version.outputs.version }}/20.04.tar.gz"

- name: Slack Notification on Failure
if: ${{ failure() }}
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/publish-nix-pgupgrade-scripts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ jobs:
id: process_release_version
run: |
VERSION=$(nix run nixpkgs#yq -- '.postgres_release["postgres'${{ matrix.postgres_version }}'"]' ansible/vars.yml)
VERSION=$(echo $VERSION | tr -d '"') # Remove any surrounding quotes
VERSION=$(echo "$VERSION" | tr -d '"') # Remove any surrounding quotes
if [[ "${{ inputs.postgresVersion }}" != "" ]]; then
VERSION=${{ inputs.postgresVersion }}
VERSION="${{ inputs.postgresVersion }}"
fi
echo "version=$VERSION" >> "$GITHUB_OUTPUT"

Expand All @@ -71,7 +71,7 @@ jobs:

- name: Upload pg_upgrade scripts to s3 staging
run: |
aws s3 cp /tmp/pg_upgrade_scripts.tar.gz s3://${{ secrets.ARTIFACTS_BUCKET }}/upgrades/postgres/supabase-postgres-${{ steps.process_release_version.outputs.version }}/pg_upgrade_scripts.tar.gz
aws s3 cp /tmp/pg_upgrade_scripts.tar.gz "s3://${{ secrets.ARTIFACTS_BUCKET }}/upgrades/postgres/supabase-postgres-${{ steps.process_release_version.outputs.version }}/pg_upgrade_scripts.tar.gz"

- name: Slack Notification on Failure
if: ${{ failure() }}
Expand Down Expand Up @@ -102,9 +102,9 @@ jobs:
id: process_release_version
run: |
VERSION=$(nix run nixpkgs#yq -- '.postgres_release["postgres'${{ matrix.postgres_version }}'"]' ansible/vars.yml)
VERSION=$(echo $VERSION | tr -d '"') # Remove any surrounding quotes
VERSION=$(echo "$VERSION" | tr -d '"') # Remove any surrounding quotes
if [[ "${{ inputs.postgresVersion }}" != "" ]]; then
VERSION=${{ inputs.postgresVersion }}
VERSION="${{ inputs.postgresVersion }}"
fi
echo "version=$VERSION" >> "$GITHUB_OUTPUT"

Expand All @@ -122,7 +122,7 @@ jobs:

- name: Upload pg_upgrade scripts to s3 prod
run: |
aws s3 cp /tmp/pg_upgrade_scripts.tar.gz s3://${{ secrets.PROD_ARTIFACTS_BUCKET }}/upgrades/postgres/supabase-postgres-${{ steps.process_release_version.outputs.version }}/pg_upgrade_scripts.tar.gz
aws s3 cp /tmp/pg_upgrade_scripts.tar.gz "s3://${{ secrets.PROD_ARTIFACTS_BUCKET }}/upgrades/postgres/supabase-postgres-${{ steps.process_release_version.outputs.version }}/pg_upgrade_scripts.tar.gz"

- name: Slack Notification on Failure
if: ${{ failure() }}
Expand Down
10 changes: 7 additions & 3 deletions .github/workflows/qemu-image-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ on:
- 'ansible/vars.yml'
workflow_dispatch:

permissions:
contents: read
id-token: write

jobs:
prepare:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -68,7 +72,7 @@ jobs:
run: |
curl -L https://github.com/mikefarah/yq/releases/download/v4.45.1/yq_linux_arm64 -o yq && chmod +x yq
PG_VERSION=$(./yq '.postgres_release["postgres'${{ matrix.postgres_version }}'"]' ansible/vars.yml)
PG_VERSION=$(echo $PG_VERSION | tr -d '"') # Remove any surrounding quotes
PG_VERSION=$(echo "$PG_VERSION" | tr -d '"') # Remove any surrounding quotes
echo 'postgres-version = "'$PG_VERSION'"' > common-nix.vars.pkr.hcl
echo 'postgres-major-version = "'$POSTGRES_MAJOR_VERSION'"' >> common-nix.vars.pkr.hcl
# Ensure there's a newline at the end of the file
Expand Down Expand Up @@ -122,8 +126,8 @@ jobs:
REPOSITORY: postgres-vm-image
IMAGE_TAG: ${{ steps.process_release_version.outputs.version }}
run: |
docker build -f Dockerfile-kubernetes -t $REGISTRY/$REGISTRY_ALIAS/$REPOSITORY:$IMAGE_TAG .
docker push $REGISTRY/$REGISTRY_ALIAS/$REPOSITORY:$IMAGE_TAG
docker build -f Dockerfile-kubernetes -t "$REGISTRY/$REGISTRY_ALIAS/$REPOSITORY:$IMAGE_TAG" .
docker push "$REGISTRY/$REGISTRY_ALIAS/$REPOSITORY:$IMAGE_TAG"

# - name: Upload software manifest to s3 staging
# run: |
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ on:
- develop
pull_request:
workflow_dispatch:

permissions:
contents: read
id-token: write

jobs:
prepare:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -57,7 +62,7 @@ jobs:
run: echo "POSTGRES_MAJOR_VERSION=${{ matrix.postgres_version }}" >> $GITHUB_ENV
- name: Strip quotes from pg major and set env var
run: |
stripped_version=$(echo ${{ matrix.postgres_version }} | sed 's/^"\(.*\)"$/\1/')
stripped_version=$(echo "${{ matrix.postgres_version }}" | sed 's/^"\(.*\)"$/\1/')
echo "PGMAJOR=$stripped_version" >> $GITHUB_ENV
- name: Generate common-nix.vars.pkr.hcl
run: |
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/testinfra-nix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ on:
pull_request:
workflow_dispatch:

permissions:
contents: read
id-token: write

jobs:
prepare:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -66,7 +70,7 @@ jobs:
- name: Generate common-nix.vars.pkr.hcl
run: |
PG_VERSION=$(sudo nix run nixpkgs#yq -- '.postgres_release["postgres'${{ matrix.postgres_version }}'"]' ansible/vars.yml)
PG_VERSION=$(echo $PG_VERSION | tr -d '"') # Remove any surrounding quotes
PG_VERSION=$(echo "$PG_VERSION" | tr -d '"') # Remove any surrounding quotes
echo 'postgres-version = "'$PG_VERSION'"' > common-nix.vars.pkr.hcl
# Ensure there's a newline at the end of the file
echo "" >> common-nix.vars.pkr.hcl
Expand Down
Loading