Skip to content

On Code Change

On Code Change #338

name: On Code Change
on:
workflow_dispatch:
schedule:
- cron: "0 0 * * *"
push:
branches:
- main
- "jdk-.*"
env:
cci_src_image: cimg/openjdk:11.0.20-node
jobs:
build:
name: Buid and push Docker Images
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@main
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Creating tag from CircleCI image
shell: bash
run: |
echo "CCI_SRC_IMAGE=${{ env.cci_src_image }}" >> $GITHUB_ENV
echo "JAHIA_TAG=$(echo ${{ env.cci_src_image }} | sed -r 's/[:\/]+/_/g')" >> $GITHUB_ENV
echo "FROM_IMAGE=jahia/cimg-mvn-cache:$(echo ${{ env.cci_src_image }} | sed -r 's/[:\/]+/_/g')" >> $GITHUB_ENV
- name: Printing CircleCI image tags
shell: bash
run: |
echo "CCI_SRC_IMAGE=${CCI_SRC_IMAGE}"
echo "JAHIA_TAG=${JAHIA_TAG}"
echo "FROM_IMAGE=${FROM_IMAGE}"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- uses: webfactory/[email protected]
with:
ssh-private-key: |
${{ secrets.BASTION_SSH_PRIVATE_KEY_JAHIACI }}
${{ secrets.GH_SSH_PRIVATE_KEY_JAHIACI }}
- name: Build and push CircleCI Docker image
uses: docker/build-push-action@v3
with:
ssh: default
push: true
tags: jahia/cimg-mvn-cache:${{ env.JAHIA_TAG }}
build-args: |
CCI_SRC_IMAGE=${{ env.CCI_SRC_IMAGE }}
- name: Build and push Github Actions Docker image
uses: docker/build-push-action@v3
with:
ssh: default
push: true
tags: jahia/cimg-mvn-cache:ga_${{ env.JAHIA_TAG }}
file: Dockerfile-github
build-args: |
FROM_IMAGE=${{ env.FROM_IMAGE }}
CCI_SRC_IMAGE=${{ env.CCI_SRC_IMAGE }}