Skip to content

githubofkrishnadhas creting or updating test in programatically-create-delete-update-github-repository-secrets #4

githubofkrishnadhas creting or updating test in programatically-create-delete-update-github-repository-secrets

githubofkrishnadhas creting or updating test in programatically-create-delete-update-github-repository-secrets #4

name: create_or_update_repository_secrets
on:
workflow_dispatch:
inputs:
organization:
required: true
description: 'GitHub Organization name'
type: string
repository_name:
required: true
description: 'GitHub repository on which secret need to be created'
type: string
secret_name:
required: true
description: 'Repository Secret name'
type: string
secret_value:
required: true
description: 'secret content'
run-name: ${{ github.actor }} creting or updating ${{ inputs.secret_name }} in ${{ inputs.repository_name }}
jobs:
create_or_update_repository_secrets:
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: |
pipenv run python3 get_repository_public_key.py --organization ${{ inputs.organization }} \
--repository_name ${{ inputs.repository_name }}
- name: Encrypt secret
id: encrypt-secret
env:
REPOSITORY_PUBLIC_KEY: ${{ env.REPOSITORY_PUBLIC_KEY }}
SECRET_VALUE: ${{ inputs.secret_value }}
run: |
pipenv run python3 encrypt_using_libnacl.py
- name: create or update repository secret
env:
organization: ${{ inputs.organization }}
secret_name: ${{ inputs.secret_name }}
ENCRYPTED_SECRET: ${{ env.ENCRYPTED_SECRET }}
REPOSITORY_PUBLIC_KEY_ID: ${{ env.REPOSITORY_PUBLIC_KEY_ID }}
GH_TOKEN: ${{ secrets.DEVWITHKRISHNA_PERSONAL_ACCESS_TOKEN }}
run: |
pipenv run python3 create_or_update_repo_secret.py
- name: Completed
run: |
echo "program completed successfully"