Push to docker #42
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: Push to docker | |
on: | |
push: | |
tags: | |
- 'v[0-9]+.[0-9]+.[0-9]+' | |
workflow_dispatch: | |
jobs: | |
test: | |
name: Testing stage (Test before deployment) | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
with: | |
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal access token. | |
fetch-depth: 0 # otherwise, there would be errors pushing refs to the destination repository. | |
- name: Setup go | |
uses: actions/setup-go@v2 | |
with: | |
go-version: '1.21.0' | |
- uses: actions/cache@v2 | |
with: | |
path: ~/go/pkg/mod | |
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | |
restore-keys: | | |
${{ runner.os }}-go- | |
- name: Run Test | |
run: | | |
go test -v hsfl.de/group6/hsfl-master-ai-cloud-engineering/... | |
push: | |
name: Building stage (Build and push to docker hub registry) | |
needs: [test] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build and push (default) | |
working-directory: ./ | |
run: | | |
docker-compose -f docker-compose.push.yml build | |
docker-compose -f docker-compose.push.yml push | |
- name: Check and set release version | |
run: | | |
echo "RELEASE_VERSION=${{ github.ref_name }}" >> $GITHUB_ENV | |
echo "RELEASE_VERSION: '$RELEASE_VERSION'" | |
- if: ${{ github.ref_name != '' }} | |
name: Build and push (versioned) | |
working-directory: ./ | |
run: | | |
docker-compose -f docker-compose.push.yml build | |
docker-compose -f docker-compose.push.yml push |