Skip to content

Commit

Permalink
add pdfsrv workflows (#91)
Browse files Browse the repository at this point in the history
add workflow for staging
  • Loading branch information
libracoder authored Sep 19, 2023
1 parent 3482518 commit 6c9bfb6
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 8 deletions.
24 changes: 23 additions & 1 deletion .github/workflows/main-crossplane.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ on:
env:
required: true
type: string
zip_lambda_workflow_step:
required: true
type: boolean
commit_hash:
required: true
type: string

permissions:
id-token: write
Expand Down Expand Up @@ -49,27 +55,34 @@ jobs:

- name: Build lambdas
run: cd ${{ github.workspace }} && make lambda
if: ${{env.zip_lambda_workflow_step==true}}
env:
GITHUB_TOKEN: ${{ secrets.GB_TOKEN_PRIVATE }}
GOPRIVATE: "github.com/vimeda/*"
zip_lambda_workflow_step: ${{ inputs.zip_lambda_workflow_step }}

- name: Upload Build Artifacts
uses: actions/upload-artifact@v2
if: ${{env.zip_lambda_workflow_step==true}}
with:
name: srv-lambdas
path: ${{ github.workspace }}/dist/*
zip_lambda_workflow_step: ${{ inputs.zip_lambda_workflow_step }}

- uses: actions/download-artifact@v2
id: download
if: ${{env.zip_lambda_workflow_step==true}}
with:
name: srv-lambdas
path: ${{ github.workspace }}/dist
zip_lambda_workflow_step: ${{ inputs.zip_lambda_workflow_step }}

- name: Display structure of downloaded files
run: ls -R
working-directory: ${{ steps.download.outputs.download-path }}

- name: Push all functions to Bucket
if: ${{env.zip_lambda_workflow_step==true}}
run: |
cd ${{ github.workspace }}/dist && ls
for file in "./"/*lambda.zip
Expand All @@ -78,6 +91,8 @@ jobs:
function_name=${filename%_lambda}
aws s3 cp "$file" "s3://${{inputs.env}}-lykon-lambdas/${{ github.event.repository.name}}/$function_name.zip"
done
env:
zip_lambda_workflow_step: ${{ inputs.zip_lambda_workflow_step }}


- uses: hashicorp/setup-terraform@v1
Expand Down Expand Up @@ -112,11 +127,18 @@ jobs:
cat $file
fi
done
env:
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.STAGING_ONEPASSWORD_SERVICEACCOUNT_TOKEN }}
VAULT_ID: "errsir3kqd4gdjgaxliofyskey"

- name: patch claim image uri with commit hash
id: patch_image_uri_with_commit_hash
run: |
find ./ -type f -name "*.yaml" -exec sed -i -e 's/COMMIT_HASH/${{ env.commit_hash }}/g' -e 's/ECR_BASE_URL/279707217826.dkr.ecr.eu-central-1.amazonaws.com\/lykon/g' {} \;
env:
TF_WORKSPACE: ${{ inputs.env }}
commit_hash: ${{ inputs.commit_hash }}

- name: Terraform apply
id: apply
run: |
Expand Down
21 changes: 20 additions & 1 deletion .github/workflows/pr-crossplane.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ on:
env:
required: true
type: string
zip_lambda_workflow_step:
required: true
type: boolean
commit_hash:
required: true
type: string

permissions:
id-token: write
Expand All @@ -30,7 +36,6 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 15


defaults:
run:
working-directory: ${{ inputs.working_directory }}
Expand All @@ -49,21 +54,27 @@ jobs:

- name: Build lambdas
run: cd ${{ github.workspace }} && make lambda
if: ${{env.zip_lambda_workflow_step==true}}
env:
GITHUB_TOKEN: ${{ secrets.GB_TOKEN_PRIVATE }}
GOPRIVATE: "github.com/vimeda/*"
zip_lambda_workflow_step: ${{ inputs.zip_lambda_workflow_step }}

- name: Upload Build Artifacts
uses: actions/upload-artifact@v2
if: ${{env.zip_lambda_workflow_step==true}}
with:
name: srv-lambdas
path: ${{ github.workspace }}/dist/*
zip_lambda_workflow_step: ${{ inputs.zip_lambda_workflow_step }}

- uses: actions/download-artifact@v2
id: download
if: ${{env.zip_lambda_workflow_step==true}}
with:
name: srv-lambdas
path: ${{ github.workspace }}/dist
zip_lambda_workflow_step: ${{ inputs.zip_lambda_workflow_step }}

- name: Display structure of downloaded files
run: ls -R
Expand Down Expand Up @@ -109,6 +120,14 @@ jobs:
VAULT_ID: "errsir3kqd4gdjgaxliofyskey"
ENV: ${{ inputs.env }}

- name: patch claim image uri with commit hash
id: patch_image_uri_with_commit_hash
run: |
find ./ -type f -name "*.yaml" -exec sed -i -e 's/COMMIT_HASH/${{ env.commit_hash }}/g' -e 's/ECR_BASE_URL/279707217826.dkr.ecr.eu-central-1.amazonaws.com\/lykon/g' {} \;
env:
TF_WORKSPACE: ${{ inputs.env }}
commit_hash: ${{ inputs.commit_hash }}

- name: Terraform Plan
id: plan
run: |
Expand Down
18 changes: 12 additions & 6 deletions .github/workflows/scripts/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,27 @@ def process_file(filename):
with open(filename, 'r') as file:
existing_yaml_data_list = list(yaml.safe_load_all(file))

# Find the 'kind: XLambda' document in the list of documents
xlambda_documents = [doc for doc in existing_yaml_data_list if doc.get('kind') == 'XLambda']
# Find the 'kind: xLambda or XLambdaDockerImage' document in the list of documents
xlambda_documents = [doc for doc in existing_yaml_data_list if doc.get('kind') in ['XLambda', 'XLambdaDockerImage']]


if not xlambda_documents:
print(f"No 'kind: XLambda' document found in {filename}.")
print("not cached")
print(f"No 'kind: xLambda or XLambdaDockerImage' document found in {filename}.")
return

# Assuming there is only one 'kind: XLambda' document, take the first one
# Assuming there is only one 'kind: xLambda or XLambdaDockerImage' document, take the first one
xlambda_document = xlambda_documents[0]

# Merge the parsed JSON with the existing YAML for the 'kind: XLambda' document
# Merge the parsed JSON with the existing YAML for the 'kind: xLambda or XLambdaDockerImage' document
parsed_json = json.loads(json_output)
print("DEBUG: parse json")
print(parsed_json)
merged_yaml_data = merge_yaml_with_json(xlambda_document, parsed_json['envVariables']['variables'])

# Update the 'kind: XLambda' document in the list
print("after parsed script")

# Update the 'kind: xLambda or XLambdaDockerImage' document in the list
existing_yaml_data_list[existing_yaml_data_list.index(xlambda_document)] = merged_yaml_data

# Write the updated YAML back to the file
Expand Down

0 comments on commit 6c9bfb6

Please sign in to comment.