Create jekyll-gh-pages.yml #19
This file contains hidden or 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
| # GitHub recommends pinning actions to a commit SHA. | |
| # To get a newer version, you will need to update the SHA. | |
| # You can also reference a tag or branch, but the action may change without warning. | |
| name: Build, Test and Publish Container | |
| on: | |
| # via github UI | |
| workflow_dispatch: | |
| # schedule: | |
| # - cron: '18 20 * * *' | |
| push: | |
| branches: [ '*' ] | |
| # Publish semver tags as releases. | |
| tags: [ 'v*.*.*' ] | |
| pull_request: | |
| branches: [ "main" ] | |
| env: | |
| # Use docker.io for Docker Hub if empty | |
| # REGISTRY: ghcr.io | |
| REGISTRY: docker.io | |
| # github.repository as <account>/<repo> | |
| IMAGE_NAME: ${{ github.repository }} | |
| jobs: | |
| build_test_and_publish: | |
| name: Build, Test and Push Container image to Docker Hub | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out the repo | |
| uses: actions/checkout@v3 | |
| - name: Build & Run webapp | |
| run: | | |
| docker build -t webapp . | |
| docker network create webapptest | |
| docker run --rm -d --network webapptest --name webapp webapp | |
| - name: Build & Run Run webapp tests | |
| run: | | |
| docker build -t webapptest test | |
| docker run --rm --network webapptest --name webapptest webapptest | |
| - name: Stop webapp | |
| run: | | |
| docker stop webapp | |
| - name: Log in to registry - ${{ env.REGISTRY }} | |
| uses: docker/[email protected] | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ secrets.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_PASSWORD }} | |
| - name: Extract metadata (tags, labels) for Docker | |
| id: meta | |
| uses: docker/[email protected] | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
| flavor: | | |
| latest=false | |
| tags: | | |
| type=schedule | |
| type=ref,event=branch | |
| type=ref,event=tag | |
| type=ref,event=pr | |
| type=raw,value=latest,enable={{is_default_branch}} | |
| - name: Build and push Docker image | |
| uses: docker/[email protected] | |
| with: | |
| context: . | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} |