Release Containerimage #74
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: Release Containerimage | |
on: | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
jobs: | |
build-test-push: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
name: checkout | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
cache: maven | |
- name: Build (and test) project with Maven | |
run: mvn -B package --file pom.xml | |
# set the env.BRANCH_NAME variable | |
- uses: nelonoel/[email protected] | |
- name: Set outputs | |
id: vars | |
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT | |
# set the env.COMMIT variable | |
- run: echo "COMMIT=$(git rev-parse --short HEAD)" >> $GITHUB_ENV | |
# build the container image and release it as a package in this repository | |
- uses: mr-smithers-excellent/docker-build-push@v6 | |
name: push-container-image | |
with: | |
image: mega-backend | |
registry: ghcr.io | |
dockerfile: Containerfile | |
buildArgs: COMMIT=${{ env.COMMIT}}, BRANCH=${{ env.BRANCH_NAME}}, VERSION=${{ env.COMMIT}} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
# if the branch is main, add the latest tag | |
addLatest: ${{ github.ref == 'refs/heads/main' }} |