-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update actions #28
Update actions #28
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
name: docker-build | ||
description: 'Setup up docker and login' | ||
inputs: | ||
context: | ||
description: 'Folder path where Dockerfile is located' | ||
required: false | ||
default: './' | ||
multiarch: | ||
description: 'Decides if arm build is required' | ||
required: false | ||
default: 'false' | ||
name: | ||
description: 'Image name' | ||
required: true | ||
tag: | ||
description: 'Image tag' | ||
required: true | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: export tag name | ||
id: export_tag_name_and_platforms | ||
shell: bash | ||
env: | ||
BUILD_NUMBER: ${{ github.run_id }} | ||
MULTIARCH: ${{ inputs.multiarch }} | ||
TAG_NAME: ${{ inputs.tag }} | ||
run: | | ||
echo "tag_name=$(echo "${{ env.TAG_NAME }}")" >> $GITHUB_OUTPUT | ||
echo "platforms=$(if [ "${{ env.MULTIARCH }}" != "true" ]; then echo "linux/amd64"; else echo "linux/arm64,linux/amd64"; fi)" >> $GITHUB_OUTPUT | ||
|
||
- name: Build and push | ||
uses: docker/build-push-action@v6 | ||
env: | ||
PROJECT: ${{ inputs.name }} | ||
with: | ||
no-cache: true | ||
push: true | ||
tags: allthings/${{ env.PROJECT }}:${{ steps.export_tag_name_and_platforms.outputs.tag_name }} | ||
platforms: ${{ steps.export_tag_name_and_platforms.outputs.platforms }} | ||
context: ${{ inputs.context }} | ||
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,39 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
name: print-logs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
description: 'Prints logs by given path' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
inputs: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
path: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
description: 'Location of logs' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
required: true | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
runs: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
using: "composite" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
steps: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
- name: Set PATH | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
shell: bash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
run: | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
echo "/bin" >> $GITHUB_PATH | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
echo "/sbin" >> $GITHUB_PATH | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
echo "/usr/bin" >> $GITHUB_PATH | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
echo "/usr/sbin" >> $GITHUB_PATH | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
echo "/usr/local/bin" >> $GITHUB_PATH | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
echo "/usr/local/sbin" >> $GITHUB_PATH | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
- name: print logs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
shell: bash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
working-directory: ${{ inputs.path }} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
run: > | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
for log in ./*; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
do | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if [ -d ./"$log" ]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
for logInDir in "$log"/*; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
do | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
echo "::group::$logInDir"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
/bin/cat "$logInDir"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
echo "::endgroup::"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
done; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
echo "::group::$log"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
/bin/cat "$log"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
echo "::endgroup::"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
fi; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
done | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+21
to
+39
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Improve readability and efficiency of log printing steps. The current logic is correct but can be improved for readability and efficiency. Consider using - for log in ./*;
- do
- if [ -d ./"$log" ]; then
- for logInDir in "$log"/*;
- do
- echo "::group::$logInDir";
- /bin/cat "$logInDir";
- echo "::endgroup::";
- done;
- else
- echo "::group::$log";
- /bin/cat "$log";
- echo "::endgroup::";
- fi;
- done
+ find . -type f | while read log;
+ do
+ echo "::group::$log";
+ /bin/cat "$log";
+ echo "::endgroup::";
+ done Committable suggestion
Suggested change
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,41 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
name: retry-script | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
description: 'Retries provided script' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
inputs: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
script: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
description: 'Location of file' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
required: true | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
attempts: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
description: 'Attempt until failure' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
required: true | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
runs: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
using: "composite" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
steps: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
- name: Set PATH | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
shell: bash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
run: | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
echo "/bin" >> $GITHUB_PATH | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
echo "/sbin" >> $GITHUB_PATH | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
echo "/usr/bin" >> $GITHUB_PATH | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
echo "/usr/sbin" >> $GITHUB_PATH | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
echo "/usr/local/bin" >> $GITHUB_PATH | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
echo "/usr/local/sbin" >> $GITHUB_PATH | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
- name: retry script | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
shell: bash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
env: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
SCRIPT: ${{ inputs.script }} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
MAX_ATTEMPTS: ${{ inputs.attempts }} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
run: > | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
set +e && for i in $(seq 1 "${{ env.MAX_ATTEMPTS }}"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
do | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
${{ env.SCRIPT }}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
res="$?"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if [[ "$res" == "0" ]]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
exit "$res"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
fi; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if [[ "$i" == "${{ env.MAX_ATTEMPTS }}" ]]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
exit "$res"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
fi; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
echo "::warning title=Retry::Current run $i failed of ${{ env.MAX_ATTEMPTS }} attempts"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
done | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+24
to
+41
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Improve readability and efficiency of script retrying steps. The current logic is correct but can be improved for readability and efficiency. Consider using a function to encapsulate the retry logic. - set +e && for i in $(seq 1 "${{ env.MAX_ATTEMPTS }}");
- do
- ${{ env.SCRIPT }};
- res="$?";
- if [[ "$res" == "0" ]]; then
- exit "$res";
- fi;
- if [[ "$i" == "${{ env.MAX_ATTEMPTS }}" ]]; then
- exit "$res";
- fi;
- echo "::warning title=Retry::Current run $i failed of ${{ env.MAX_ATTEMPTS }} attempts";
- done
+ retry() {
+ for i in $(seq 1 "$1"); do
+ $2
+ res="$?"
+ if [[ "$res" == "0" ]]; then
+ return 0
+ fi
+ echo "::warning title=Retry::Current run $i failed of $1 attempts"
+ done
+ return "$res"
+ }
+ set +e
+ retry "${{ env.MAX_ATTEMPTS }}" "${{ env.SCRIPT }}"
+ exit "$?" Committable suggestion
Suggested change
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
name: upload-artifacts | ||
description: 'Uploads files to s3' | ||
inputs: | ||
path: | ||
description: 'Location of files' | ||
required: true | ||
runner-id: | ||
description: 'Id of runner as an identifier' | ||
required: true | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Set PATH | ||
shell: bash | ||
run: | | ||
echo "/bin" >> $GITHUB_PATH | ||
echo "/sbin" >> $GITHUB_PATH | ||
echo "/usr/bin" >> $GITHUB_PATH | ||
echo "/usr/sbin" >> $GITHUB_PATH | ||
echo "/usr/local/bin" >> $GITHUB_PATH | ||
echo "/usr/local/sbin" >> $GITHUB_PATH | ||
|
||
- name: upload files | ||
shell: bash | ||
working-directory: ${{ inputs.path }} | ||
env: | ||
RUNNER_BUCKET: s3://agent-artifacts-eu-west-1/${{ github.run_id }}/runner-${{ inputs.runner-id }}-${{ github.run_attempt }} | ||
run: > | ||
aws-vault exec --backend=pass allthings-development-github-role --duration=12h -- | ||
aws s3 cp --region=eu-west-1 --recursive "./" "${{ env.RUNNER_BUCKET }}" --acl bucket-owner-full-control | ||
|
||
- name: print file links | ||
shell: bash | ||
working-directory: ${{ inputs.path }} | ||
env: | ||
RUNNER_BUCKET: s3://agent-artifacts-eu-west-1/${{ github.run_id }}/runner-${{ inputs.runner-id }}-${{ github.run_attempt }} | ||
run: > | ||
while IFS= read -r runnerFile; | ||
do | ||
filePath=$(echo "$runnerFile" | grep -Po "\d+\/.*"); fileName=$(echo "$filePath" | sed 's/.*\///'); | ||
echo "$fileName"; | ||
echo "https://allthings-github-artifacts.auth.eu-west-1.amazoncognito.com/oauth2/authorize?response_type=token&client_id=7pn0enn1f29m6ghpdik78hkp33&redirect_uri=https://cksj34aqloivipgg7nsw6exyam0zogkq.lambda-url.eu-west-1.on.aws&scope=aws.cognito.signin.user.admin+openid+profile&state=$(echo "$filePath" | jq --slurp --raw-input --raw-output @uri | sed 's/%0A$//')"; | ||
done <<< "$(aws-vault exec --backend=pass allthings-development-github-role --duration=12h -- aws s3 ls --region=eu-west-1 --recursive "${{ env.RUNNER_BUCKET }}")" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Improve readability and efficiency of Docker build and push steps.
The current logic is correct but can be improved for readability and efficiency. Consider using environment variables to simplify the inputs.
Committable suggestion