Skip to content

Commit c6f05ca

Browse files
authored
Merge pull request #30 from mottljan/feature/add-github-actions
Add GitHub actions
2 parents d008d46 + c41b95d commit c6f05ca

5 files changed

Lines changed: 134 additions & 1 deletion

File tree

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Common preflight check
2+
description: Action that contains common checks like building and testing the image. Requires login to dhi.io for getting hardened base image.
3+
4+
inputs:
5+
image-tag:
6+
description: "Tag of the Ackee Android GitLab builder image"
7+
required: true
8+
9+
runs:
10+
using: "composite"
11+
steps:
12+
- name: Build image
13+
shell: bash
14+
env:
15+
# Required for building the image
16+
IMAGE_TAG: ${{ inputs.image-tag }}
17+
# Run shai-hulud detector in paranoid mode to perform more thorough checks
18+
run: docker compose build --build-arg SHAI_HULUD_DETECTOR_MODE=--paranoid
19+
20+
- name: Test image
21+
shell: bash
22+
env:
23+
# Required for testing the image
24+
IMAGE_TAG: ${{ inputs.image-tag }}
25+
# Give others write permission so the unprivileged user inside a container can write to the folder during Gradle build
26+
run: |
27+
chmod -R o+w image-test-app
28+
docker compose run --rm gitlab-builder-android
29+
30+
- name: Image lint
31+
# dockle is cool and targets exactly what we want to check but looks kinda dead right now. So
32+
# far better than nothing but we might need to explore alternative options in the future.
33+
uses: erzz/dockle-action@v1
34+
with:
35+
image: ackee/gitlab-builder-android:${{ inputs.image-tag }}
36+
exit-code: 1

.github/actions/login/action.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Login
2+
description: Action that performs login to Docker Hub and dhi.io
3+
4+
inputs:
5+
user-name:
6+
description: "Docker Hub user name"
7+
required: true
8+
token:
9+
description: "Docker Hub PAT"
10+
required: true
11+
12+
runs:
13+
using: "composite"
14+
steps:
15+
- name: Login to Docker Hub
16+
uses: docker/login-action@v3
17+
with:
18+
registry: docker.io
19+
username: ${{ inputs.user-name }}
20+
password: ${{ inputs.token }}
21+
22+
- name: Login to dhi.io
23+
uses: docker/login-action@v3
24+
with:
25+
registry: dhi.io
26+
username: ${{ inputs.user-name }}
27+
password: ${{ inputs.token }}

.github/workflows/deploy.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Deploy
2+
3+
on:
4+
push:
5+
tags:
6+
- v*
7+
8+
jobs:
9+
deploy:
10+
runs-on: ubuntu-24.04
11+
steps:
12+
- name: Check out code
13+
uses: actions/checkout@v6
14+
15+
# We need to login to dhi.io for getting hardened base image and to Docker Hub for pushing the image
16+
- name: Login
17+
uses: ./.github/actions/login
18+
with:
19+
user-name: ${{ secrets.DOCKER_HUB_USERNAME }}
20+
token: ${{ secrets.DOCKER_HUB_TOKEN }}
21+
22+
- name: Preflight checks
23+
uses: ./.github/actions/common-preflight-check
24+
with:
25+
image-tag: ${{ github.ref_name }}
26+
27+
- name: Push image
28+
shell: bash
29+
run: docker compose push

.github/workflows/pull_request.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Pull request
2+
3+
on:
4+
pull_request:
5+
types:
6+
- opened
7+
- synchronize
8+
9+
jobs:
10+
pull_request:
11+
runs-on: ubuntu-24.04
12+
permissions:
13+
# Allows docker/scout-action to write a comment to PR
14+
pull-requests: write
15+
steps:
16+
- name: Check out code
17+
uses: actions/checkout@v6
18+
19+
# We need to login to dhi.io for getting hardened base image and to Docker Hub for using Docker Scout
20+
- name: Login
21+
uses: ./.github/actions/login
22+
with:
23+
user-name: ${{ secrets.DOCKER_HUB_USERNAME }}
24+
token: ${{ secrets.DOCKER_HUB_TOKEN }}
25+
26+
- name: Preflight checks
27+
uses: ./.github/actions/common-preflight-check
28+
with:
29+
image-tag: "pr"
30+
31+
# We run Docker Scout to check for CVEs only in the PR because we just want to see a report of
32+
# vulnerabilities without failing the build (and this behaviour is useless for deploy workflow).
33+
# We don't want to ever fail even on critical fixable CVEs because they can come from transitive
34+
# dependencies that we don't control and can't usually reliably patch.
35+
- name: Docker Scout
36+
uses: docker/scout-action@v1
37+
with:
38+
command: "cves"
39+
only-severities: "critical,high"
40+
# Report only CVEs that have a fix available
41+
only-fixed: true

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
.idea/
1+
.DS_Store

0 commit comments

Comments
 (0)