Build Docker Container #249
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: docker | |
run-name: Build Docker Container | |
on: | |
push: | |
branches: | |
- main | |
paths: | |
- "src/**" | |
- "package.json" | |
pull_request: | |
branches: | |
- main | |
paths: | |
- "src/**" | |
- "package.json" | |
workflow_dispatch: # Also allow manual triggering | |
jobs: | |
docker: | |
env: | |
dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }} | |
dockerhub_token: ${{ secrets.DOCKERHUB_TOKEN }} | |
name: Publish Docker Image | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Install GitVersion | |
uses: gittools/actions/gitversion/setup@v0.10.2 | |
with: | |
versionSpec: "5.x" | |
- name: Run GitVersion | |
uses: gittools/actions/gitversion/execute@v0.10.2 | |
with: | |
useConfigFile: true | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to Docker Hub | |
if: ${{ env.dockerhub_username != '' && env.dockerhub_token != '' }} | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ env.dockerhub_username }} | |
password: ${{ env.dockerhub_token }} | |
- name: Determine image version | |
# shell: bash | |
run: | | |
if [[ $GITHUB_EVENT_NAME == "pull_request" ]]; then | |
echo "IMAGE_VERSION=${{ env.GitVersion_MajorMinorPatch }}-beta" >> $GITHUB_ENV | |
else | |
echo "IMAGE_VERSION=${{ env.GitVersion_MajorMinorPatch }}" >> $GITHUB_ENV | |
fi | |
- name: Build and push (PR) | |
uses: docker/build-push-action@v5 | |
if: ${{ github.event_name == 'pull_request' && env.dockerhub_username != '' && env.dockerhub_token != '' }} | |
with: | |
push: true | |
tags: | | |
dickwolff/export-to-ghostfolio:${{ env.IMAGE_VERSION }} | |
build-args: | | |
IMAGE_VERSION=${{ env.IMAGE_VERSION }} | |
platforms: linux/amd64,linux/arm64 | |
- name: Build and push (main) | |
uses: docker/build-push-action@v5 | |
if: ${{ github.event_name != 'pull_request' && env.dockerhub_username != '' && env.dockerhub_token != '' }} | |
with: | |
push: true | |
tags: | | |
dickwolff/export-to-ghostfolio:latest | |
dickwolff/export-to-ghostfolio:${{ env.IMAGE_VERSION }} | |
build-args: | | |
IMAGE_VERSION=${{ env.IMAGE_VERSION }} | |
platforms: linux/amd64,linux/arm64 |