Skip to content

githubofkrishnadhas creating secrets in devwithkrishna #8

githubofkrishnadhas creating secrets in devwithkrishna

githubofkrishnadhas creating secrets in devwithkrishna #8

name: create-organization-github-secrets-from-workflow
on:
workflow_dispatch:
inputs:
organization:
type: string
default: 'devwithkrishna'
description: 'The GitHub organization where the repository will be created.'
required: true
secret_name:
type: string
description: "Secret name to create/update on org level"
required: true
secret_value:
type: string
description: "Secret value to add"
required: true
run-name: ${{ github.actor }} creating secrets in ${{ inputs.organization }}
jobs:
create-organization-github-secrets-from-workflow:
runs-on: ubuntu-latest
steps:
- name: git checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.11'
- name: package installations
run: |
pip install pipenv
pipenv install
- name: get public key
id: get-public-key
env:
GH_TOKEN: ${{ secrets.DEVWITHKRISHNA_PERSONAL_ACCESS_TOKEN }}
run: |
public_key=$(bash get_public_key.sh ${{inputs.organization}})
echo "::set-output name=public_key::$public_key"
- name: Encrypt secret
id: encrypt-secret
env:
PUBLIC_KEY: ${{ steps.get-public-key.outputs.public_key }}
SECRET_VALUE: ${{ inputs.secret_value }}
run: |
pipenv run python3 encrypt_using_libnacl.py
- name: create or update org secret
env:
organization: ${{ inputs.organization }}
secret_name: ${{ inputs.secret_name }}
GH_TOKEN: ${{ secrets.DEVWITHKRISHNA_PERSONAL_ACCESS_TOKEN }}
run: |
pipenv run python3 update_github_org_secret.py
- name: Completed
run: |
echo "program completed successfully"