Skip to content

Commit 8ecf4fb

Browse files
committed
Add image scanner to build process
1 parent cdddb8c commit 8ecf4fb

File tree

3 files changed

+81
-41
lines changed

3 files changed

+81
-41
lines changed

Diff for: .github/workflows/build.yml

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
on:
2+
workflow_call:
3+
4+
jobs:
5+
build:
6+
name: Build Docker image
7+
runs-on: ubuntu-latest
8+
env:
9+
GENERATOR_IMAGE_NAME: decidim/decidim-generator
10+
TEST_IMAGE_NAME: decidim/decidim-test
11+
DEV_IMAGE_NAME: decidim/decidim-dev
12+
APP_IMAGE_NAME: decidim/decidim
13+
TAG: ${{ github.sha }}
14+
steps:
15+
- name: Fetch Decidim Tag
16+
id: decidim-tag
17+
uses: oprypin/find-latest-tag@v1
18+
with:
19+
repository: decidim/decidim
20+
releases-only: true
21+
22+
- name: Set Ruby Version
23+
id: ruby-version
24+
env:
25+
RUBY_VERSION_URL: https://raw.githubusercontent.com/decidim/decidim/${{ steps.decidim-tag.outputs.tag }}/.ruby-version
26+
run: |
27+
echo ::set-output name=version::$(curl -s $RUBY_VERSION_URL)
28+
- name: Set Decidim Version
29+
id: decidim-version
30+
run: echo ::set-output name=version::$(echo ${{ steps.decidim-tag.outputs.tag }} | cut -c2-)
31+
32+
- name: Checkout Our Repo
33+
uses: actions/checkout@v2
34+
35+
- name: Build decidim-generator Image
36+
env:
37+
RUBY_VERSION: ${{ steps.ruby-version.outputs.version }}
38+
DECIDIM_VERSION: ${{ steps.decidim-version.outputs.version }}
39+
run: |
40+
docker build \
41+
--build-arg ruby_version=$RUBY_VERSION \
42+
--build-arg decidim_version=$DECIDIM_VERSION \
43+
--file Dockerfile-generator \
44+
-t $GENERATOR_IMAGE_NAME .
45+
docker tag $GENERATOR_IMAGE_NAME $GENERATOR_IMAGE_NAME:$TAG
46+
docker tag $GENERATOR_IMAGE_NAME ghcr.io/$GENERATOR_IMAGE_NAME:$TAG
47+
docker tag $GENERATOR_IMAGE_NAME $GENERATOR_IMAGE_NAME:$DECIDIM_VERSION
48+
docker tag $GENERATOR_IMAGE_NAME ghcr.io/$GENERATOR_IMAGE_NAME:$DECIDIM_VERSION
49+
-
50+
name: Scan for vulnerabilities
51+
id: scan
52+
uses: crazy-max/ghaction-container-scan@v3
53+
with:
54+
image: decidim/decidim-generator
55+
dockerfile: ./Dockerfile-generator

Diff for: .github/workflows/dockerhub.yml

+10-41
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,18 @@ on:
66
branches:
77
- master
88
paths:
9-
- 'Dockerfile'
10-
- 'Dockerfile-test'
11-
- 'Dockerfile-dev'
12-
- 'Dockerfile-generator'
13-
- '.github/workflows/dockerhub.yml'
9+
- "*"
10+
- 'Dockerfile'
11+
- 'Dockerfile-test'
12+
- 'Dockerfile-dev'
13+
- 'Dockerfile-generator'
14+
- '.github/workflows/dockerhub.yml'
1415

1516
jobs:
17+
build:
18+
uses: ./.github/workflows/build.yml
19+
secrets: inherit
20+
name: Build image
1621
build-publish:
1722
name: Build & Publish Docker Images
1823
runs-on: ubuntu-latest
@@ -24,42 +29,6 @@ jobs:
2429
TAG: ${{ github.sha }}
2530

2631
steps:
27-
- name: Fetch Decidim Tag
28-
id: decidim-tag
29-
uses: oprypin/find-latest-tag@v1
30-
with:
31-
repository: decidim/decidim
32-
releases-only: true
33-
34-
- name: Set Ruby Version
35-
id: ruby-version
36-
env:
37-
RUBY_VERSION_URL: https://raw.githubusercontent.com/decidim/decidim/${{ steps.decidim-tag.outputs.tag }}/.ruby-version
38-
run: |
39-
echo ::set-output name=version::$(curl -s $RUBY_VERSION_URL)
40-
41-
- name: Set Decidim Version
42-
id: decidim-version
43-
run: echo ::set-output name=version::$(echo ${{ steps.decidim-tag.outputs.tag }} | cut -c2-)
44-
45-
- name: Checkout Our Repo
46-
uses: actions/checkout@v2
47-
48-
- name: Build decidim-generator Image
49-
env:
50-
RUBY_VERSION: ${{ steps.ruby-version.outputs.version }}
51-
DECIDIM_VERSION: ${{ steps.decidim-version.outputs.version }}
52-
run: |
53-
docker build \
54-
--build-arg ruby_version=$RUBY_VERSION \
55-
--build-arg decidim_version=$DECIDIM_VERSION \
56-
--file Dockerfile-generator \
57-
-t $GENERATOR_IMAGE_NAME .
58-
docker tag $GENERATOR_IMAGE_NAME $GENERATOR_IMAGE_NAME:$TAG
59-
docker tag $GENERATOR_IMAGE_NAME ghcr.io/$GENERATOR_IMAGE_NAME:$TAG
60-
docker tag $GENERATOR_IMAGE_NAME $GENERATOR_IMAGE_NAME:$DECIDIM_VERSION
61-
docker tag $GENERATOR_IMAGE_NAME ghcr.io/$GENERATOR_IMAGE_NAME:$DECIDIM_VERSION
62-
6332
- name: Publish decidim-generator Image to Docker Hub
6433
uses: docker/login-action@v1
6534
with:

Diff for: .github/workflows/test.yml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: "Test Current PR"
2+
on:
3+
pull_request:
4+
paths:
5+
- "*"
6+
- ".github/**"
7+
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
10+
cancel-in-progress: true
11+
12+
jobs:
13+
build:
14+
uses: ./.github/workflows/build.yml
15+
secrets: inherit
16+
name: Build image

0 commit comments

Comments
 (0)