Update GitHub Actions #4
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 test Docker image | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
env: | |
IMAGE_NAME: ${{ github.repository }} | |
jobs: | |
build-image: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Build Docker image | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
push: false | |
tags: ${{ env.IMAGE_NAME }}:latest | |
- name: List Docker images | |
run: docker images | |
- name: Run Docker container | |
run: | | |
docker run --name test-container -d ${{ env.IMAGE_NAME }}:latest | |
sleep 5 | |
docker logs test-container | |
docker stop test-container |