Create .gitlab-ci.yml #4
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
# This workflow is managed by https://github.com/raft-tech/df-gh-templates. All attempts to edit outside of df-gh-templates will be futile. | |
name: DEV - Build and Push 'dev' Docker Image | |
on: | |
push: | |
branches: | |
- dev | |
paths-ignore: | |
- 'VERSION' | |
env: | |
GHCR_REGISTRY: ghcr.io | |
GHCR_REPOSITORY: raft-tech | |
IB_REGISTRY: registry1.dso.mil | |
IMAGE_NAME: ${{ vars.IMAGE_NAME }} | |
CONTEXT_PATH: ${{ vars.CONTEXT_PATH || '.' }} | |
DOCKERFILE_PATH: ${{ vars.DOCKERFILE_PATH || 'Dockerfile' }} | |
OPTIONAL_TAG: ${{ vars.OPTIONAL_TAG }} | |
TAG: dev | |
jobs: | |
docker: | |
runs-on: ${{ vars.DOCKER_JOBS_RUNS_ON || 'ubuntu-latest' }} | |
steps: | |
# - name: Random Delay to avoid DDoS behavior against registries. | |
# run: sleep $((RANDOM % 31)) | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: List Files | |
run: ls | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to GHCR | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.GHCR_REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Login to registry1 | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.IB_REGISTRY }} | |
username: ${{ secrets.IB_USER }} | |
password: ${{ secrets.IB_PASS }} | |
- name: Build and push - GHCR | |
if: env.OPTIONAL_TAG == '' | |
uses: docker/build-push-action@v5 | |
with: | |
context: ${{ env.CONTEXT_PATH }} | |
file: ${{ env.DOCKERFILE_PATH }} | |
platforms: linux/amd64,linux/arm64 | |
push: true | |
tags: | | |
${{ env.GHCR_REGISTRY }}/${{ env.GHCR_REPOSITORY }}/${{ env.IMAGE_NAME }}:${{ env.TAG }} | |
- name: Build and push - GHCR (Optional Tag) | |
if: env.OPTIONAL_TAG != '' | |
uses: docker/build-push-action@v5 | |
with: | |
context: ${{ env.CONTEXT_PATH }} | |
file: ${{ env.DOCKERFILE_PATH }} | |
platforms: linux/amd64,linux/arm64 | |
push: true | |
tags: | | |
${{ env.GHCR_REGISTRY }}/${{ env.GHCR_REPOSITORY }}/${{ env.IMAGE_NAME }}:${{ env.TAG }} | |
${{ env.GHCR_REGISTRY }}/${{ env.GHCR_REPOSITORY }}/${{ env.IMAGE_NAME }}:${{ env.OPTIONAL_TAG }} |