Skip to content

Create Nginx image

Create Nginx image #29

name: Create Nginx image
on:
workflow_dispatch:
push:
branches: [ "main" ]
paths:
- 'contrib/docker-ckan/nginx/**'
jobs:
build-Nginx-image:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- name: Validate prerequisites
uses: ahmadnassri/action-workflow-run-wait@v1
with:
timeout: 15000 # we stop trying to check altogether after 15 secs because there is no delay set up; this prevents hanging if the workflow is cancelled
# delay: 60000 # we try to check the status of the prerequisite workflows after 1 min
- 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: 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
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@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/nginx/Dockerfile
context: ./contrib/docker-ckan/nginx
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-nginx:${{ steps.sha.outputs.sha }}
${{ secrets.CONTAINER_REGISTRY_URL }}/mdepckan/ckan-nginx:latest
# labels: ${{ steps.docker_meta.outputs.labels }}