Skip to content

update registries and improve GHA #37

update registries and improve GHA

update registries and improve GHA #37

name: Build API Container
on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:
env:
REGISTRY: ghcr.io
REPO: r-techsupport
IMAGE: webdbg-api
jobs:
build_and_push:
runs-on: windows-2022
permissions:
contents: write
pull-requests: write
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
submodules: true
- name: Set short SHA
run: echo "SHORT_SHA=${GITHUB_SHA::7}" >> $GITHUB_ENV
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
run: |

Check failure on line 41 in .github/workflows/bsod-api-container.yaml

View workflow run for this annotation

GitHub Actions / Build API Container

Invalid workflow file

The workflow is not valid. .github/workflows/bsod-api-container.yaml (Line: 41, Col: 12): Unexpected symbol: 'env:REPO'. Located at position 1 within expression: env:REPO
if ($env:GITHUB_REF -eq 'refs/heads/main') {
$TAG = 'latest'
} else {
$TAG = 'devel'
}
docker build -t ${{ env.REGISTRY }}/${{ env:REPO }}/${{ env:IMAGE }}:$TAG -t ${{ env:REGISTRY }}/${{ env:REPO }}/${{ env:IMAGE }}:${{ env:SHORT_SHA }} api/
docker push ${{ env:REGISTRY }}/${{ env:REPO }}/${{ env:IMAGE }}:$TAG
docker push ${{ env:REGISTRY }}/${{ env:REPO }}/${{ env:IMAGE }}:${{ env:SHORT_SHA }}
- name: Log out from the Container registry
run: docker logout ${{ env.REGISTRY }}
- name: Comment on the PR
if: github.event_name == 'pull_request'
uses: actions/github-script@v6
with:
script: |
const tag = '${{ env.REGISTRY }}/${{ env.REPO }}/${{ env.IMAGE }}:${{ env.TAG }}';
const shortSha = '${{ env.REGISTRY }}/${{ env.REPO }}/${{ env.IMAGE }}:${{ env.SHORT_SHA }}';
github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: `Docker images have been built and pushed:\n- \`${tag}\`\n- \`${shortSha}\``
});