Release v0.3.1 #28
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: Build and Publish Docker Image | |
on: | |
release: | |
types: [published, released] | |
permissions: | |
contents: read | |
packages: write | |
jobs: | |
docker: | |
runs-on: ubuntu-latest | |
outputs: | |
version: ${{ steps.get_version.outputs.version }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Get release version | |
id: get_version | |
run: | | |
VERSION=${GITHUB_REF#refs/tags/} | |
echo "VERSION=$VERSION" >> $GITHUB_ENV | |
echo "IS_PRERELEASE=${{ github.event.release.prerelease }}" >> $GITHUB_ENV | |
echo "version=$VERSION" >> $GITHUB_OUTPUT | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push release | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
push: true | |
tags: | | |
ghcr.io/${{ github.repository }}:${{ steps.get_version.outputs.version }} | |
${{ github.event.release.prerelease == false && format('ghcr.io/{0}:latest', github.repository) || '' }} | |
labels: | | |
org.opencontainers.image.version=${{ steps.get_version.outputs.version }} | |
org.opencontainers.image.revision=${{ github.sha }} | |
org.opencontainers.image.title=${{ github.event.repository.name }} | |
org.opencontainers.image.description=Pull Request Analysis Bot | |
org.opencontainers.image.source=${{ github.event.repository.html_url }} | |
retag-latest: | |
needs: docker | |
if: ${{ !github.event.release.prerelease }} | |
runs-on: ubuntu-latest | |
permissions: | |
packages: write | |
steps: | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Pull new version | |
run: | | |
docker pull ghcr.io/${{ github.repository }}:${{ needs.docker.outputs.version }} | |
- name: Tag and push as latest | |
run: | | |
docker tag ghcr.io/${{ github.repository }}:${{ needs.docker.outputs.version }} ghcr.io/${{ github.repository }}:latest | |
docker push ghcr.io/${{ github.repository }}:latest |