update ci to copy multiple files to s3 #2
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on: | ||
workflow_call: | ||
inputs: | ||
role_name: | ||
required: true | ||
type: string | ||
role_session_name: | ||
required: true | ||
type: string | ||
aws_region: | ||
required: false | ||
type: string | ||
default: eu-central-1 | ||
working_directory: | ||
required: true | ||
type: string | ||
function_names: | ||
required: true | ||
type: array | ||
env: | ||
required: true | ||
type: string | ||
permissions: | ||
id-token: write | ||
contents: read | ||
pull-requests: write | ||
statuses: write | ||
jobs: | ||
terraform: | ||
name: Terraform | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 15 | ||
defaults: | ||
run: | ||
working-directory: ${{ inputs.working_directory }} | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
- name: Configure AWS Credentials | ||
id: aws | ||
uses: aws-actions/configure-aws-credentials@v2 | ||
with: | ||
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/${{ inputs.role_name }} | ||
role-session-name: ${{ inputs.role_session_name }} | ||
aws-region: ${{ inputs.aws_region }} | ||
- name: Build lambdas | ||
run: cd ${{ github.workspace }} && make lambda | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GB_TOKEN_PRIVATE }} | ||
GOPRIVATE: "github.com/vimeda/*" | ||
- name: Upload Build Artifacts | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: upload-artifcats | ||
path: ${{ github.workspace }}/dist/* | ||
- uses: actions/download-artifact@v2 | ||
id: download | ||
with: | ||
name: download artificacts | ||
path: ${{ github.workspace }}/dist | ||
- name: Display structure of downloaded files | ||
run: ls -R | ||
working-directory: ${{ steps.download.outputs.download-path }} | ||
- name: Push function to Bucket | ||
run: | | ||
cd ${{ github.workspace }}/dist | ||
cd ${{ github.workspace }}/dist | ||
for name in ${{ inputs.function_names }} | ||
do | ||
aws s3 cp "${name}_lambda.zip" "s3://${{ inputs.env }}-lykon-lambdas/${name}/function.zip" | ||
done | ||
# aws s3 cp ${{ inputs.function_name }}_lambda.zip s3://${{ inputs.env }}-lykon-lambdas/${{ inputs.function_name }}/function.zip | ||
- uses: hashicorp/setup-terraform@v1 | ||
with: | ||
terraform_version: ~1.0 | ||
- name: Terraform Init | ||
id: init | ||
run: terraform -chdir=${{ github.workspace }}/configs/crossplane/${{ inputs.env }} init | ||
- uses: actions/download-artifact@v2 | ||
id: downloadscripts | ||
with: | ||
name: scripts | ||
path: ./scripts | ||
- name: copy scripts to scripts folder in working directory | ||
run: | | ||
mkdir ./scripts && ls | ||
cp -r ${{ github.workspace }}/scripts/.github/workflows ./scripts | ||
shell: sh | ||
- name: Install 1Password Cli and patch claim | ||
run: | | ||
curl https://cache.agilebits.com/dist/1P/op2/pkg/v2.18.0/op_linux_amd64_v2.18.0.zip > op.zip | ||
unzip op.zip | ||
sudo mv op /usr/local/bin | ||
rm op.zip | ||
ls | ||
python -m pip install ruamel.yaml | ||
python scripts/workflows/scripts/patch_claim.py | ||
for file in *-claims.yaml; do | ||
if [ -f "$file" ]; then | ||
cat "$file" | ||
fi | ||
done | ||
env: | ||
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.STAGING_ONEPASSWORD_SERVICEACCOUNT_TOKEN }} | ||
VAULT_ID: "errsir3kqd4gdjgaxliofyskey" | ||
- name: Terraform apply | ||
id: apply | ||
run: | | ||
echo "${{ secrets.STAGING_KUBECONFIG }}" > ${{ github.workspace }}/kubeconfig.yaml | ||
export KUBECONFIG=${{ github.workspace }}/kubeconfig.yaml | ||
terraform -chdir=${{ github.workspace }}/configs/crossplane/${{ inputs.env }} apply -auto-approve | ||
env: | ||
TF_WORKSPACE: ${{ inputs.env }} |