CI to publish docker images #7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and publish Docker Images | |
on: | |
push: | |
branches: [ "master" ] | |
paths: | |
- 'docker/enclave-base/**' | |
- 'docker/parent-base/**' | |
pull_request: | |
branches: [ "master" ] | |
paths: | |
- 'docker/enclave-base/**' | |
- 'docker/parent-base/**' | |
jobs: | |
build-docker-images: | |
runs-on: ubuntu-20.04 | |
# if: github.event_name == 'pull_request' && github.event.action == 'opened' | |
steps: | |
- name: Pull main repository | |
uses: actions/checkout@v3 | |
with: | |
repository: fortanix/salmiac | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build and export enclave-base | |
uses: docker/build-push-action@v5 | |
with: | |
context: docker/enclave-base | |
file: docker/enclave-base/Dockerfile | |
tags: fortanix/enclave-base:latest | |
outputs: type=tar,dest=/tmp/enclave-base.tar | |
- name: Upload enclave-base artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: enclave-base | |
path: /tmp/enclave-base.tar | |
- name: Build and export parent-base | |
uses: docker/build-push-action@v5 | |
with: | |
context: docker/parent-base | |
file: docker/parent-base/Dockerfile | |
tags: fortanix/parent-base:latest | |
outputs: type=tar,dest=/tmp/parent-base.tar | |
- name: Upload parent-base artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: parent-base | |
path: /tmp/parent-base.tar | |
push-docker-images: | |
runs-on: ubuntu-20.04 | |
needs: build-docker-images | |
# if: github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true | |
steps: | |
- name: Download enclave-base artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: enclave-base | |
path: /tmp/enclave-base.tar | |
- name: Load enclave-base image | |
run: | | |
docker load --input /tmp/enclave-base.tar | |
- name: Download parent-base artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: parent-base | |
path: /tmp/parent-base.tar | |
- name: Load parent-base image | |
run: | | |
docker load --input /tmp/parent-base.tar | |
- name: Login to Docker Hub | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Push docker images | |
run: | | |
docker push fortanix/enclave-base | |
docker push fortanix/parent-base |