-
Notifications
You must be signed in to change notification settings - Fork 0
89 lines (74 loc) · 2.88 KB
/
docker-base-image.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
name: Create Ckan Base image
on:
workflow_dispatch:
push:
branches: [ "main" ]
paths-ignore:
- '.github/workflows/cypress.yml'
- '.github/workflows/tests.yml'
- '.github/workflows/docker-dev-image.yml'
- '.github/workflows/docker-nginx-image.yml'
- '.github/workflows/docker-postgresql-image.yml'
- '.github/workflows/docker-deployment-image.yml'
- '.github/workflows/deploy.yml'
- '.github/ISSUE_TEMPLATE'
- '.github/PULL_REQUEST_TEMPLATE.md'
- 'contrib/docker-ckan/postgresql/**'
- 'contrib/docker-ckan/nginx/**'
- 'contrib/docker-ckan/dev-base/**'
- 'contrib/docker-ckan/dev-deploy/**'
- 'contrib/docker-ckan/prod/**'
- 'contrib/docker-ckan/docker-compose.dev.yml'
- 'contrib/docker-ckan/docker-compose.yml'
- 'contrib/docker-ckan/dev.env.template'
- 'contrib/docker-ckan/prod.env.template'
jobs:
build-base-image:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
role-to-assume: ${{ secrets.ROLE_OIDC }}
aws-region: eu-west-2
role-session-name: CKANDockerDeployment
- name: Login into the Container Registry
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
# TODO: use Docker Metadata action in the future to manage the semantic versioning of images
- name: Set sha output
id: sha
run: echo "::set-output name=sha::$(git rev-parse --short HEAD)"
- name: Build and push
id: docker_build
uses: docker/build-push-action@v3
with:
file: ./contrib/docker-ckan/base/Dockerfile
context: .
platforms: linux/amd64
builder: ${{ steps.buildx.outputs.name }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
# don't push the image if it's a pull request, only build it which is a way of testing if the image can be successfully built
push: ${{ github.event_name != 'pull_request' }}
tags: |
${{ secrets.CONTAINER_REGISTRY_URL }}/mdepckan/ckan-base:${{ steps.sha.outputs.sha }}
${{ secrets.CONTAINER_REGISTRY_URL }}/mdepckan/ckan-base:latest
# labels: ${{ steps.docker_meta.outputs.labels }}
build-args: |
INTERNAL_REG=${{ secrets.CONTAINER_REGISTRY_URL }}