Commit f257964 1 parent ffbf083 commit f257964 Copy full SHA for f257964
File tree 4 files changed +166
-0
lines changed
4 files changed +166
-0
lines changed Original file line number Diff line number Diff line change
1
+ name: docker-build
2
+ description: 'Setup up docker and login'
3
+ inputs:
4
+ context:
5
+ description: 'Folder path where Dockerfile is located'
6
+ required: false
7
+ default: './'
8
+ multiarch:
9
+ description: 'Decides if arm build is required'
10
+ required: false
11
+ default: 'false'
12
+ name:
13
+ description: 'Image name'
14
+ required: true
15
+ tag:
16
+ description: 'Image tag'
17
+ required: true
18
+
19
+ runs:
20
+ using: "composite"
21
+ steps:
22
+ - name: export tag name
23
+ id: export_tag_name_and_platforms
24
+ shell: bash
25
+ env:
26
+ BUILD_NUMBER: ${{ github.run_id }}
27
+ MULTIARCH: ${{ inputs.multiarch }}
28
+ TAG_NAME: ${{ inputs.tag }}
29
+ run: |
30
+ echo "tag_name=$(echo "${{ env.TAG_NAME }}")" >> $GITHUB_OUTPUT
31
+ echo "platforms=$(if [ "${{ env.MULTIARCH }}" != "true" ]; then echo "linux/amd64"; else echo "linux/arm64,linux/amd64"; fi)" >> $GITHUB_OUTPUT
32
+
33
+ - name: Build and push
34
+ uses: docker/build-push-action@v6
35
+ env:
36
+ PROJECT: ${{ inputs.name }}
37
+ with:
38
+ no-cache: true
39
+ push: true
40
+ tags: allthings/${{ env.PROJECT }}:${{ steps.export_tag_name_and_platforms.outputs.tag_name }}
41
+ platforms: ${{ steps.export_tag_name_and_platforms.outputs.platforms }}
42
+ context: ${{ inputs.context }}
Original file line number Diff line number Diff line change
1
+ name: print-logs
2
+ description: 'Prints logs by given path'
3
+ inputs:
4
+ path:
5
+ description: 'Location of logs'
6
+ required: true
7
+
8
+ runs:
9
+ using: "composite"
10
+ steps:
11
+ - name: Set PATH
12
+ shell: bash
13
+ run: |
14
+ echo "/bin" >> $GITHUB_PATH
15
+ echo "/sbin" >> $GITHUB_PATH
16
+ echo "/usr/bin" >> $GITHUB_PATH
17
+ echo "/usr/sbin" >> $GITHUB_PATH
18
+ echo "/usr/local/bin" >> $GITHUB_PATH
19
+ echo "/usr/local/sbin" >> $GITHUB_PATH
20
+
21
+ - name: print logs
22
+ shell: bash
23
+ working-directory: ${{ inputs.path }}
24
+ run: >
25
+ for log in ./*;
26
+ do
27
+ if [ -d ./"$log" ]; then
28
+ for logInDir in "$log"/*;
29
+ do
30
+ echo "::group::$logInDir";
31
+ /bin/cat "$logInDir";
32
+ echo "::endgroup::";
33
+ done;
34
+ else
35
+ echo "::group::$log";
36
+ /bin/cat "$log";
37
+ echo "::endgroup::";
38
+ fi;
39
+ done
Original file line number Diff line number Diff line change
1
+ name: retry-script
2
+ description: 'Retries provided script'
3
+ inputs:
4
+ script:
5
+ description: 'Location of file'
6
+ required: true
7
+ attempts:
8
+ description: 'Attempt until failure'
9
+ required: true
10
+
11
+ runs:
12
+ using: "composite"
13
+ steps:
14
+ - name: Set PATH
15
+ shell: bash
16
+ run: |
17
+ echo "/bin" >> $GITHUB_PATH
18
+ echo "/sbin" >> $GITHUB_PATH
19
+ echo "/usr/bin" >> $GITHUB_PATH
20
+ echo "/usr/sbin" >> $GITHUB_PATH
21
+ echo "/usr/local/bin" >> $GITHUB_PATH
22
+ echo "/usr/local/sbin" >> $GITHUB_PATH
23
+
24
+ - name: retry script
25
+ shell: bash
26
+ env:
27
+ SCRIPT: ${{ inputs.script }}
28
+ MAX_ATTEMPTS: ${{ inputs.attempts }}
29
+ run: >
30
+ set +e && for i in $(seq 1 "${{ env.MAX_ATTEMPTS }}");
31
+ do
32
+ ${{ env.SCRIPT }};
33
+ res="$?";
34
+ if [[ "$res" == "0" ]]; then
35
+ exit "$res";
36
+ fi;
37
+ if [[ "$i" == "${{ env.MAX_ATTEMPTS }}" ]]; then
38
+ exit "$res";
39
+ fi;
40
+ echo "::warning title=Retry::Current run $i failed of ${{ env.MAX_ATTEMPTS }} attempts";
41
+ done
Original file line number Diff line number Diff line change
1
+ name: upload-artifacts
2
+ description: 'Uploads files to s3'
3
+ inputs:
4
+ path:
5
+ description: 'Location of files'
6
+ required: true
7
+ runner-id:
8
+ description: 'Id of runner as an identifier'
9
+ required: true
10
+
11
+ runs:
12
+ using: "composite"
13
+ steps:
14
+ - name: Set PATH
15
+ shell: bash
16
+ run: |
17
+ echo "/bin" >> $GITHUB_PATH
18
+ echo "/sbin" >> $GITHUB_PATH
19
+ echo "/usr/bin" >> $GITHUB_PATH
20
+ echo "/usr/sbin" >> $GITHUB_PATH
21
+ echo "/usr/local/bin" >> $GITHUB_PATH
22
+ echo "/usr/local/sbin" >> $GITHUB_PATH
23
+
24
+ - name: upload files
25
+ shell: bash
26
+ working-directory: ${{ inputs.path }}
27
+ env:
28
+ RUNNER_BUCKET: s3://agent-artifacts-eu-west-1/${{ github.run_id }}/runner-${{ inputs.runner-id }}-${{ github.run_attempt }}
29
+ run: >
30
+ aws-vault exec --backend=pass allthings-development-github-role --duration=12h --
31
+ aws s3 cp --region=eu-west-1 --recursive "./" "${{ env.RUNNER_BUCKET }}" --acl bucket-owner-full-control
32
+
33
+ - name: print file links
34
+ shell: bash
35
+ working-directory: ${{ inputs.path }}
36
+ env:
37
+ RUNNER_BUCKET: s3://agent-artifacts-eu-west-1/${{ github.run_id }}/runner-${{ inputs.runner-id }}-${{ github.run_attempt }}
38
+ run: >
39
+ while IFS= read -r runnerFile;
40
+ do
41
+ filePath=$(echo "$runnerFile" | grep -Po "\d+\/.*"); fileName=$(echo "$filePath" | sed 's/.*\///');
42
+ echo "$fileName";
43
+ 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$//')";
44
+ done <<< "$(aws-vault exec --backend=pass allthings-development-github-role --duration=12h -- aws s3 ls --region=eu-west-1 --recursive "${{ env.RUNNER_BUCKET }}")"
You can’t perform that action at this time.
0 commit comments