Create testWebhook #8
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: Publish container image using the last commit SHA as an image tag | |
on: | |
pull_request: # run on pull requests | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: ${{ github.repository }}-api | |
jobs: | |
build-and-publish-image: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Check out the repo | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.ref }} # This dynamically references the branch you trigger the workflow from | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Get short SHA from PR head commit | |
id: get_sha | |
if: ${{ github.event_name == 'pull_request' }} | |
run: echo "SHORT_SHA=$(echo '${{ github.event.pull_request.head.sha }}' | cut -c1-7)" >> $GITHUB_ENV | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v3 | |
with: | |
context: . | |
file: Dockerfile.api | |
push: true | |
tags: | | |
${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:${{ env.SHORT_SHA }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max |