Produce pretty lint results in GitHub Actions #6
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 deploy images | |
on: | |
schedule: | |
# rebuild every 16th day of the month at 15:24 UTC | |
- cron: '24 15 16 * *' | |
push: | |
branches: | |
- main | |
- feature/** | |
- bugfix/** | |
pull_request: | |
branches: | |
- '*' | |
permissions: | |
contents: read | |
packages: write | |
actions: read | |
jobs: | |
build-image: | |
name: Build image | |
runs-on: ubuntu-latest | |
env: | |
image: ghcr.io/seravo/phpcs | |
steps: | |
- id: refname | |
name: Convert git refname to valid Docker tag | |
run: echo "refname=$(echo "${{ github.ref_name }}" |sed 's/\//-/g')" >> $GITHUB_OUTPUT | |
- id: clone-repository | |
uses: actions/checkout@v4 | |
name: Clone git repository | |
with: | |
submodules: true | |
- id: docker-login | |
uses: Seravo/actions/[email protected] | |
name: Login to ghcr.io | |
# To speed up builds, try to use previously built image as cache source. | |
# However, skip this if we're running weekly scheduled build to ensure | |
# that we get latest APT versions at least once a week | |
- if: ${{ github.event_name != 'schedule' }} | |
name: Pull previously built image | |
id: docker-pull | |
uses: Seravo/actions/[email protected] | |
with: | |
image: "${{ env.image }}" | |
- id: docker-build | |
uses: Seravo/actions/[email protected] | |
name: Build image | |
with: | |
image: "${{ env.image }}" | |
- if: ${{ github.ref == 'refs/heads/main' }} | |
name: Push new image to production | |
id: docker-push-master | |
uses: Seravo/actions/[email protected] | |
with: | |
image: "${{ env.image }}" | |
- id: docker-tag-push-commit | |
name: Tag image with commit id | |
uses: Seravo/actions/[email protected] | |
with: | |
source: "${{ env.image }}" | |
target: "${{ env.image }}:${{ github.sha }}" | |
- id: docker-tag-push-refname | |
name: Tag image with refname | |
uses: Seravo/actions/[email protected] | |
with: | |
source: "${{ env.image }}" | |
target: "${{ env.image }}:${{ steps.refname.outputs.refname }}" |