Don't log in if docker builds are not required #66
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 Self Contained Image | |
permissions: | |
contents: write | |
packages: write | |
'on': | |
workflow_dispatch: {} | |
push: | |
paths: | |
- '**/*' | |
- '!.github/badges/*' | |
- '!README.md' | |
- '!python/**/*' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Install GitVersion | |
uses: gittools/actions/gitversion/setup@v0.9.15 | |
with: | |
versionSpec: 5.x | |
- id: determine_version | |
name: Determine Version | |
uses: gittools/actions/gitversion/execute@v0.9.15 | |
with: | |
additionalArguments: /overrideconfig mode=Mainline | |
- name: Get branch name | |
id: branch-name | |
uses: tj-actions/branch-names@v7 | |
- name: Login to DockerHub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
# The Docker image used to run workers | |
- name: Build, tag, and push worker image to Dockerhub | |
if: ${{ steps.branch-name.outputs.current_branch == 'main' }} | |
run: | | |
docker build -f docker/selfcontained/Dockerfile -t octopussamples/octopub-selfcontained:${{ steps.determine_version.outputs.semVer }} . | |
docker push octopussamples/octopub-selfcontained:${{ steps.determine_version.outputs.semVer }} | |
docker tag octopussamples/octopub-selfcontained:${{ steps.determine_version.outputs.semVer }} octopussamples/octopub-selfcontained:latest | |
docker push octopussamples/octopub-selfcontained:latest | |
shell: bash |