Skip to content

Release/3.5.0

Release/3.5.0 #229

name: DockerPRPublish
on:
pull_request:
jobs:
DockerPRPublish:
if: "! github.event.pull_request.head.repo.fork "
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Determine version
env:
PR_NUMBER: ${{ github.event.number }}
run: |
echo "I found version: ${{ env.PR_NUMBER }}"
echo "VERSION=${{ env.PR_NUMBER }}" >> $GITHUB_ENV
- name: Build backend
run: |
cd backend
docker build -t ghcr.io/${{ github.repository_owner }}/masz_backend_pr:${{ env.VERSION }} .
- name: Build frontend
run: |
cd nginx
docker build -t ghcr.io/${{ github.repository_owner }}/masz_nginx_pr:${{ env.VERSION }} .
- name: Push images
run: |
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u zaanposni --password-stdin
docker push ghcr.io/${{ github.repository_owner }}/masz_backend_pr:${{ env.VERSION }}
docker push ghcr.io/${{ github.repository_owner }}/masz_nginx_pr:${{ env.VERSION }}
- name: Calculate image sizes
run: |
SIZE_BACKEND=$(docker image inspect ghcr.io/${{ github.repository_owner }}/masz_backend_pr:${{ env.VERSION }} | jq -r '.[0].Size' | numfmt --to=si)
SIZE_NGINX=$(docker image inspect ghcr.io/${{ github.repository_owner }}/masz_nginx_pr:${{ env.VERSION }} | jq -r '.[0].Size' | numfmt --to=si)
echo "I found backend size: $SIZE_BACKEND"
echo "I found nginx size: $SIZE_NGINX"
echo "SIZE_BACKEND=$SIZE_BACKEND" >> $GITHUB_ENV
echo "SIZE_NGINX=$SIZE_NGINX" >> $GITHUB_ENV
- uses: actions/github-script@v5
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: "🚀 Published `masz_backend_pr:${{ env.VERSION }}` with `${{ env.SIZE_BACKEND }}`.\n🚀 Published `masz_nginx_pr:${{ env.VERSION }}` with `${{ env.SIZE_NGINX }}`.\n\nUse these images to quickly test this PR.\nYou can also commit new changes to overwrite these images."
})