Skip to content

Commit 93d78d7

Browse files
authored
add secret as parameter for update_aws_variables workflow (#99)
1 parent 363bd49 commit 93d78d7

File tree

6 files changed

+38
-15
lines changed

6 files changed

+38
-15
lines changed

.github/actions/commit_to_pullrequest/action.yml

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ description: |
44
The action expects a python script to be executed
55
66
inputs:
7+
token:
8+
description: The Github token to use to perform commit.
9+
required: true
710
python_libs:
811
description: |
912
Required libraries to execute the python script
@@ -25,9 +28,6 @@ outputs:
2528
changes_detected:
2629
description: Value is "true", if the repository was dirty and file changes have been detected. Value is "false", if no changes have been detected.
2730
value: ${{ steps.commit.outputs.changes_detected }}
28-
commit_hash:
29-
description: Full hash of the created commit. Only present if the "changes_detected" output is "true".
30-
value: ${{ steps.commit.outputs.commit_hash }}
3131

3232
runs:
3333
using: composite
@@ -58,9 +58,21 @@ runs:
5858
python /tmp/update_repository.py
5959
shell: bash
6060

61-
- name: commit and push changes
61+
- name: Commit and push changes
6262
id: commit
63-
uses: stefanzweifel/git-auto-commit-action@v4
64-
with:
65-
commit_message: ${{ inputs.commit_message }}
66-
file_pattern: ${{ inputs.file_pattern }}
63+
run: |
64+
if [[ -n $(git status -s) ]]; then
65+
echo -e "changes detected\n$(git status -s)"
66+
git add -A ${{ inputs.file_pattern }}
67+
git -c user.name="$GIT_USER_NAME" -c user.email="$GIT_USER_EMAIL" commit -m "${{ inputs.commit_message }}" --author="$GIT_AUTHOR"
68+
git push origin ${{ github.head_ref }}
69+
echo "changes_detected=true" >> $GITHUB_OUTPUT
70+
else
71+
echo "changes_detected=false" >> $GITHUB_OUTPUT
72+
fi
73+
shell: bash
74+
env:
75+
GITHUB_TOKEN: ${{ inputs.token }}
76+
GIT_USER_NAME: "github-actions[bot]"
77+
GIT_USER_EMAIL: "41898282+github-actions[bot]@users.noreply.github.com"
78+
GIT_AUTHOR: "${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>"

.github/workflows/release-branch.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ on:
77
description: The release version to create.
88
required: true
99
type: string
10+
secrets:
11+
GH_TOKEN:
12+
description: The Github token to use
13+
required: true
1014

1115
jobs:
1216
release:
@@ -40,7 +44,7 @@ jobs:
4044
git checkout -b $R_BRANCH && git push origin $R_BRANCH || git checkout $R_BRANCH
4145
shell: bash
4246
env:
43-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
47+
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
4448
RELEASE_VERSION: ${{ inputs.version }}
4549
4650
- name: setup python
@@ -75,15 +79,15 @@ jobs:
7579
shell: bash
7680
env:
7781
RELEASE_VERSION: ${{ inputs.version }}
78-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
82+
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
7983
GIT_USER_NAME: "github-actions[bot]"
8084
GIT_USER_EMAIL: "41898282+github-actions[bot]@users.noreply.github.com"
8185
GIT_AUTHOR: "${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>"
8286
8387
- name: Create Pull Request
84-
uses: abikouo/github_actions/.github/actions/create_pullrequest@release_v4
88+
uses: ansible-network/github_actions/.github/actions/create_pullrequest@main
8589
with:
86-
token: ${{ secrets.GITHUB_TOKEN }}
90+
token: ${{ secrets.GH_TOKEN }}
8791
repository: ${{ github.repository }}
8892
base_branch: ${{ steps.create-branch.outputs.release_branch }}
8993
head_branch: ${{ steps.push-changes.outputs.created_branch }}

.github/workflows/release-tag.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ jobs:
6767
GITHUB_TOKEN: ${{ secrets.gh_token }}
6868

6969
- name: Create Pull Request from Release branch to default branch
70-
uses: abikouo/github_actions/.github/actions/create_pullrequest@release_v4
70+
uses: ansible-network/github_actions/.github/actions/create_pullrequest@main
7171
with:
7272
token: ${{ secrets.gh_token }}
7373
repository: ${{ github.repository }}

.github/workflows/update_aws_variables.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
name: aws-variables
22
on:
33
workflow_call:
4+
secrets:
5+
GH_TOKEN:
6+
description: The Github token to use.
7+
required: false
48

59
jobs:
610
user-agent:
@@ -16,6 +20,7 @@ jobs:
1620
python_libs: "pyyaml"
1721
python_executable_url: "https://raw.githubusercontent.com/ansible-network/github_actions/main/scripts/update_aws_user_agent.py"
1822
file_pattern: "plugins/*.py"
23+
token: ${{ secrets.GH_TOKEN || secrets.GITHUB_TOKEN }}
1924

2025
boto-constraints:
2126
runs-on: ubuntu-latest
@@ -28,3 +33,4 @@ jobs:
2833
with:
2934
commit_message: "update botocore and boto3 tests constraints"
3035
python_executable_url: "https://raw.githubusercontent.com/ansible-network/github_actions/main/scripts/update_aws_boto_constraints.py"
36+
token: ${{ secrets.GH_TOKEN || secrets.GITHUB_TOKEN }}

scripts/update_aws_boto_constraints.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ def update_tests_constraints(boto3_version: str, botocore_version: str) -> None:
5757
"""
5858
boto_values = {"boto3": boto3_version, "botocore": botocore_version}
5959
for file in ("tests/unit/constraints.txt", "tests/integration/constraints.txt"):
60-
update_single_file(file, boto_values)
60+
if PosixPath(file).exists():
61+
update_single_file(file, boto_values)
6162

6263
min_boto_values = {
6364
"MINIMUM_BOTO3_VERSION": boto3_version,

scripts/update_aws_user_agent.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def update_user_agent(src: PosixPath, var_name: str, galaxy_version: str) -> boo
2626
variable_regex = rf"^{var_name} = [\"|'](.*)[\"|']"
2727
new_content = []
2828
updated = False
29-
logger.info("********** Parsing file => %s *************", src.stem)
29+
logger.info("********** Parsing file => %s *************", src)
3030
with src.open() as file_handler:
3131
for line in file_handler.read().split("\n"):
3232
match = re.match(variable_regex, line)

0 commit comments

Comments
 (0)