Build Containers #383
Workflow file for this run
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 Containers | |
on: | |
push: | |
branches: | |
- main | |
- 'SL*' | |
tags: | |
- '*' | |
jobs: | |
build: | |
if: github.repository_owner == 'star-bnl' | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
starenv: [root5, root6] | |
compiler: [gcc485, gcc11] | |
env: | |
STARENV: ${{ matrix.starenv }}-${{ matrix.compiler }} | |
steps: | |
- name: Get branch name | |
id: branch-name | |
uses: tj-actions/branch-names@v6 | |
- name: Define complete image tag | |
run: | | |
echo "TAG=${{ steps.branch-name.outputs.current_branch || steps.branch-name.outputs.tag }}-${{ env.STARENV }}" >> $GITHUB_ENV | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to GitHub Container Registry | |
uses: docker/#-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build a release container | |
uses: docker/build-push-action@v3 | |
with: | |
build-args: | | |
starenv=${{ matrix.starenv }} | |
compiler=${{ matrix.compiler }} | |
load: true | |
tags: ghcr.io/${{ github.repository_owner }}/star-sw:${{ env.TAG }} | |
- name: Push container image | |
run: | | |
docker push ghcr.io/${{ github.repository_owner }}/star-sw:${{ env.TAG }} | |
- name: Create latest tag for default branch | |
if: ${{ steps.branch-name.outputs.is_tag == 'false' && steps.branch-name.outputs.is_default == 'true' && env.STARENV == 'root5-gcc485' }} | |
run: | | |
docker tag ghcr.io/${{ github.repository_owner }}/star-sw:${{ env.TAG }} ghcr.io/${{ github.repository_owner }}/star-sw:latest | |
docker push ghcr.io/${{ github.repository_owner }}/star-sw:latest | |
- name: Create latest tag for SL* branches | |
if: ${{ steps.branch-name.outputs.is_tag == 'false' && steps.branch-name.outputs.is_default == 'false' && env.STARENV == 'root5-gcc485' }} | |
run: | | |
docker tag ghcr.io/${{ github.repository_owner }}/star-sw:${{ env.TAG }} ghcr.io/${{ github.repository_owner }}/star-sw:${{ steps.branch-name.outputs.current_branch }} | |
docker push ghcr.io/${{ github.repository_owner }}/star-sw:${{ steps.branch-name.outputs.current_branch }} | |
- name: Create image tag based on pushed tag | |
if: ${{ steps.branch-name.outputs.is_tag == 'true' && env.STARENV == 'root5-gcc485' }} | |
run: | | |
docker tag ghcr.io/${{ github.repository_owner }}/star-sw:${{ env.TAG }} ghcr.io/${{ github.repository_owner }}/star-sw:${{ steps.branch-name.outputs.tag }} | |
docker push ghcr.io/${{ github.repository_owner }}/star-sw:${{ steps.branch-name.outputs.tag }} | |
build-cleanup: | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- run: .github/workflows/delete_untagged.py ${{ secrets.STAR_BNL_STAR_SW_TOKEN }} |