Skip to content

Build on push to feature branch. #60

Build on push to feature branch.

Build on push to feature branch. #60

name: Build, Test, and Publish
on:
pull_request:
push:
branches: [main, develop, feature/context]
tags: ['*']
workflow_dispatch:
env:
REGISTRY: ghcr.io
BASE_IMG_REPO: project8/luna_base
BASE_IMG_TAG: v1.3.4-dev
FINAL_BASE_IMG_REPO: project8/luna_base
FINAL_BASE_IMG_TAG: v1.3.4
NARG: 2
jobs:
docker-build-and-publish:
name: Build and push the docker images
strategy:
matrix:
build: [Dev, Prod]
fail-fast: [false]
include:
- build: Dev
tag-suffix: '-dev'
build-type: Debug
build-tests: true
- build: Prod
tag-suffix: ''
build-type: Release
build-tests: false
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v4
with:
submodules: recursive
- name: Docker meta
id: docker_meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ github.repository }}
flavor: |
latest=auto
suffix=${{ matrix.tag-suffix }},onlatest=true
tags: |
type=semver,pattern={{raw}}
type=ref,event=branch
type=ref,event=pr
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
- name: Get previous tag
uses: "WyriHaximus/github-action-get-previous-tag@v1"
id: tag_name
with:
fallback: beta
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
id: setup_buildx
uses: docker/setup-buildx-action@v3
with:
buildkitd-flags: --debug
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build to Test
id: build-to-test
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile
push: false
load: true
build-args: |
build_img_repo=${{ env.REGISTRY }}/${{ env.BASE_IMG_REPO }}
build_img_tag=${{ env.BASE_IMG_TAG }}
final_img_repo=${{ env.REGISTRY }}/${{ env.FINAL_BASE_IMG_REPO }}
final_img_tag=${{ env.FINAL_BASE_IMG_TAG }}${{ matrix.tag-suffix }}
katydid_tag=${{ steps.tag_name.outputs.tag }}
build_type=${{ matrix.build-type }}
build_tests_exe=${{ matrix.build-tests }}
narg=${{ env.NARG }}
tags: test${{ matrix.tag-suffix }}
platforms: linux/amd64
# - name: Run Tests
# Alternate lines from pls testing:
# if: ${{ matrix.build-tests == true }}
# run: echo '#!/bin/bash' > job.sh && echo source /usr/local/p8/locust/${{ steps.tag_name.outputs.tag }}/setup.sh >> job.sh && echo /usr/local/p8/locust/${{ steps.tag_name.outputs.tag }}/bin/RunTests >> job.sh && chmod +x job.sh && docker run -v /home/runner/work/locust_mc/locust_mc:/tmp ${{ steps.build-to-test.outputs.imageid }} /tmp/job.sh
# End alternate lines from pls testing.
# Disabled for now because tests aren't installed
# if: false
# if: ${{ matrix.build-tests == true }}
# run: docker run ${{ steps.build-to-test.outputs.imageid }} "source /usr/local/p8/locust/${{ steps.tag_name.outputs.tag }}/setup.sh; /tmp_loc_source/build/Source/Applications/Testing/RunTests"
- name: Build to Push
id: build-to-push
if: github.event_name == 'push' && ( contains(github.ref, 'refs/tags/') || github.ref == 'refs/heads/develop' )
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile
push: true
load: false
build-args: |
build_img_repo=${{ env.REGISTRY }}/${{ env.BASE_IMG_REPO }}
build_img_tag=${{ env.BASE_IMG_TAG }}
final_img_repo=${{ env.REGISTRY }}/${{ env.FINAL_BASE_IMG_REPO }}
final_img_tag=${{ env.FINAL_BASE_IMG_TAG }}${{ matrix.tag-suffix }}
katydid_tag=${{ steps.tag_name.outputs.tag }}
build_type=${{ matrix.build-type }}
build_tests_exe=${{ matrix.build-tests }}
narg=${{ env.NARG }}
tags: ${{ steps.docker_meta.outputs.tags }}
platforms: linux/amd64
# platforms: linux/amd64,linux/arm64
- name: Release
uses: softprops/action-gh-release@v1
if: ${{ github.event_name == 'push' && contains(github.ref, 'refs/tags/') }}