Skip to content

Commit ffbf083

Browse files
feat: update action scripts (#26)
Co-authored-by: itmustbemagic <49156114+itmustbemagic@users.noreply.github.com>
1 parent 47e5b05 commit ffbf083

File tree

3 files changed

+109
-0
lines changed

3 files changed

+109
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: ddb-pipeline-status
2+
description: 'Changes the pipeline status and checks it'
3+
inputs:
4+
action:
5+
description: 'Action of progress, passed, status'
6+
required: true
7+
project:
8+
description: 'Name of project'
9+
required: true
10+
11+
runs:
12+
using: "composite"
13+
steps:
14+
- name: Set to in progress
15+
env:
16+
BRANCH_NAME: ${{ github.ref_name }}
17+
COMMAND_ACTION: ${{ inputs.action }}
18+
PROJECT: ${{ inputs.project }}
19+
TABLE_NAME: allthings-github-actions-status
20+
shell: bash
21+
run: |
22+
if [ "${{ env.COMMAND_ACTION }}" != "progress" ]; then exit 0; fi
23+
24+
keyJson="{\"pk\":{\"S\":\"${{ env.PROJECT }}-${{ env.BRANCH_NAME }}\"}}"
25+
{
26+
aws-vault exec --backend=pass allthings-development-github-role -- aws dynamodb update-item \
27+
--table-name "${{ env.TABLE_NAME }}" \
28+
--update-expression "SET passed = :status" \
29+
--expression-attribute-values '{":status":{"BOOL":false}}' \
30+
--key="$keyJson"
31+
} || {
32+
exit 1
33+
}
34+
exit 0
35+
36+
- name: Set to in passed
37+
env:
38+
BRANCH_NAME: ${{ github.ref_name }}
39+
COMMAND_ACTION: ${{ inputs.action }}
40+
PROJECT: ${{ inputs.project }}
41+
TABLE_NAME: allthings-github-actions-status
42+
shell: bash
43+
run: |
44+
if [ "${{ env.COMMAND_ACTION }}" != "passed" ]; then exit 0; fi
45+
46+
keyJson="{\"pk\":{\"S\":\"${{ env.PROJECT }}-${{ env.BRANCH_NAME }}\"}}"
47+
{
48+
aws-vault exec --backend=pass allthings-development-github-role -- aws dynamodb update-item \
49+
--table-name "${{ env.TABLE_NAME }}" --key="$keyJson" \
50+
--update-expression "SET passed = :status" \
51+
--expression-attribute-values '{":status":{"BOOL":true}}'
52+
} || {
53+
exit 1
54+
}
55+
exit 0
56+
57+
- name: Set to in passed
58+
env:
59+
BRANCH_NAME: ${{ github.ref_name }}
60+
COMMAND_ACTION: ${{ inputs.action }}
61+
PROJECT: ${{ inputs.project }}
62+
TABLE_NAME: allthings-github-actions-status
63+
shell: bash
64+
run: |
65+
if [ "${{ env.COMMAND_ACTION }}" != "status" ]; then exit 0; fi
66+
67+
keyJson="{\"pk\":{\"S\":\"${{ env.PROJECT }}-${{ env.BRANCH_NAME }}\"}}"
68+
aws-vault exec --backend=pass allthings-development-github-role -- aws dynamodb get-item \
69+
--table-name "${{ env.TABLE_NAME }}" --key="$keyJson" | grep "\"BOOL\": true" || exit 1
70+
exit 0
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: docker-setup
2+
description: 'Setup up docker and login'
3+
runs:
4+
using: "composite"
5+
steps:
6+
- name: Set up Docker Buildx
7+
uses: docker/setup-buildx-action@v3
8+
9+
- name: Set up QEMU
10+
uses: docker/setup-qemu-action@v3
11+
12+
- name: Login to Docker Hub
13+
uses: docker/login-action@v3
14+
with:
15+
username: '${{ env.DOCKER_LOGIN_USER }}'
16+
password: '${{ env.DOCKER_LOGIN_PASSWORD }}'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: slack-notifications
2+
description: 'Sends slack notification'
3+
inputs:
4+
notification-type:
5+
description: 'Type of notification like nightly-security-check'
6+
required: true
7+
8+
runs:
9+
using: "composite"
10+
steps:
11+
- name: Set to in progress
12+
env:
13+
PROJECT: ${{ env.PROJECT }}
14+
BUILD_NUMBER: ${{ github.run_id }}
15+
SLACK_GITHUB_ACTIONS_WEBHOOK: ${{ env.SLACK_GITHUB_ACTIONS_WEBHOOK }}
16+
NOTIFICATION_TYPE: ${{ inputs.notification-type }}
17+
shell: bash
18+
run: |
19+
if [ "${{ env.NOTIFICATION_TYPE }}" = "nightly-security-check" ]; then
20+
JOB_URL="https://github.com/allthings/${{ env.PROJECT }}/actions/runs/${{ env.BUILD_NUMBER }}"
21+
curl -X POST "${{ env.SLACK_GITHUB_ACTIONS_WEBHOOK }}" -H "Content-Type: application/json" \
22+
-d "{\"blocks\":[{\"text\":{\"text\":\"*Name:* ${{ env.PROJECT }} nightly security check\\n*Type:* cron-job\\n*Text:* Security check failed\\n><$JOB_URL|View failing job>\",\"type\":\"mrkdwn\"},\"type\":\"section\"}],\"text\":\"\"}"
23+
fi

0 commit comments

Comments
 (0)