Update README.md #53
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: CI | |
on: | |
push: | |
branches: | |
- master # Push events on master branch | |
pull_request: # Run tests for any PRs | |
env: | |
IMAGE_NAME: puppet-lint-action | |
jobs: | |
# Run tests. | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Docker build | |
run: docker build . --file Dockerfile --tag image | |
- name: Docker run | |
run: docker run --entrypoint puppet-lint image -v | |
# Push image to GitHub Packages. | |
# See also https://docs.docker.com/docker-hub/builds/ | |
push: | |
# Ensure test job passes before pushing image. | |
needs: test | |
runs-on: ubuntu-latest | |
permissions: | |
packages: write | |
contents: read | |
if: github.event_name == 'push' | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Build image | |
run: docker build . --file Dockerfile --tag "$IMAGE_NAME" | |
- name: Log into GitHub Container Registry | |
run: > | |
echo "${{ secrets.GITHUB_TOKEN }}" | | |
docker login https://ghcr.io -u ${{ github.actor }} --password-stdin | |
- name: Push image to GitHub Container Registry | |
run: | | |
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/"$IMAGE_NAME" | |
# Change all uppercase to lowercase | |
IMAGE_ID=$(echo "$IMAGE_ID" | tr '[:upper:]' '[:lower:]') | |
SHA="${{ github.sha }}" | |
# Strip git ref prefix from version | |
REF=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') | |
echo IMAGE_ID="$IMAGE_ID" | |
echo SHA="$SHA" | |
echo REF="$REF" | |
docker tag "$IMAGE_NAME" "$IMAGE_ID":"$SHA" | |
docker tag "$IMAGE_NAME" "$IMAGE_ID":"$REF" | |
docker push "$IMAGE_ID":"$REF" | |
docker push "$IMAGE_ID":"$SHA" |