Skip to content

added pr template (#172) #29

added pr template (#172)

added pr template (#172) #29

name: Build and Publish Docker Image
on:
push:
branches: [main]
tags:
- '*'
jobs:
build-and-publish:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-tags: true
fetch-depth: 0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Compute Version and Commit Info
id: cpfinfo
run: |
VERSION=$(cat sourcecode-parser/VERSION)
COMMIT=$(git describe --tags)
echo $VERSION
echo $COMMIT
echo "PROJECT_VERSION=${VERSION}" >> $GITHUB_OUTPUT
echo "PROJECT_COMMIT=${COMMIT}" >> $GITHUB_OUTPUT
- name: Determine Docker Tag
id: vars
run: |
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
VERSION=$(cat sourcecode-parser/VERSION)
echo "tag1=v${VERSION}" >> $GITHUB_OUTPUT
echo "tag2=stable-latest" >> $GITHUB_OUTPUT
elif [ "${{ github.event_name }}" == "push" ] && [ "${{ github.ref }}" == "refs/heads/main" ]; then
VERSION=$(cat sourcecode-parser/VERSION)
echo "tag1=dev-${VERSION}" >> $GITHUB_OUTPUT
echo "tag2=nightly-latest" >> $GITHUB_OUTPUT
else
echo "tag1=dev" >> $GITHUB_OUTPUT
echo "tag2=nightly-dev" >> $GITHUB_OUTPUT
fi
- name: Build and push to GitHub Container Registry
uses: docker/build-push-action@v5
env:
POSTHOG_WEB_ANALYTICS: ${{ secrets.POSTHOG_WEB_ANALYTICS }}
with:
context: .
platforms: linux/amd64,linux/arm64
build-args: |
POSTHOG_WEB_ANALYTICS=${{ secrets.POSTHOG_WEB_ANALYTICS }}
PROJECT_COMMIT=${{ steps.cpfinfo.outputs.PROJECT_COMMIT }}
PROJECT_VERSION=${{ steps.cpfinfo.outputs.PROJECT_VERSION }}
push: true
tags: |
ghcr.io/${{ github.repository_owner }}/code-pathfinder:${{ steps.vars.outputs.tag1 }}
ghcr.io/${{ github.repository_owner }}/code-pathfinder:${{ steps.vars.outputs.tag2 }}
- name: Build and push to Docker Hub
uses: docker/build-push-action@v5
env:
POSTHOG_WEB_ANALYTICS: ${{ secrets.POSTHOG_WEB_ANALYTICS }}
with:
context: .
push: true
platforms: linux/amd64,linux/arm64
build-args: |
POSTHOG_WEB_ANALYTICS=${{ secrets.POSTHOG_WEB_ANALYTICS }}
PROJECT_COMMIT=${{ steps.cpfinfo.outputs.PROJECT_COMMIT }}
PROJECT_VERSION=${{ steps.cpfinfo.outputs.PROJECT_VERSION }}
tags: |
${{ secrets.DOCKER_USERNAME }}/code-pathfinder:${{ steps.vars.outputs.tag1 }}
${{ secrets.DOCKER_USERNAME }}/code-pathfinder:${{ steps.vars.outputs.tag2 }}