-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
It seems that GitHub Actions can't checkout submodules during building the containerized action. So, let's build image first using GitHub Actions, publish it, and then use it for action execution. Related: <https://github.com/orgs/community/discussions/50895>
- Loading branch information
Showing
2 changed files
with
78 additions
and
1 deletion.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
--- | ||
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 }}" |
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