forked from alphagov/paas-docker-cloudfoundry-tools
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Elevate GITHUB_TOKEN permissions * Always build and push on PR (for testing built images) * Automatically detect if there are acceptance tests * Only lint on pull requests, not each commit GITHUB_TOKEN changes are documented with comments, but the TL;DR is: `actions: write`: This allows 'cancel-workflow-action' to cancel existing running actions. If another action has started on a branch / pr it's highly unlikely we care about the outputs from older ones. `statuses: write`: This allows 'super-linter' to write to commit / pr statuses, which gives an at-a-glance idea of tue results, without having to scour the job output.
- Loading branch information
Showing
26 changed files
with
290 additions
and
49 deletions.
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
--- | ||
name: Deploy | ||
on: | ||
workflow_call: | ||
|
@@ -13,10 +14,6 @@ on: | |
tag_suffix: | ||
type: string | ||
description: "Optional suffix for all tags" | ||
has_acceptance_tests: | ||
default: false | ||
type: boolean | ||
description: "Specify if acceptance tests are needed for this image" | ||
push: | ||
default: true | ||
type: boolean | ||
|
@@ -47,6 +44,10 @@ jobs: | |
deploy: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Cancel Previous Runs | ||
uses: styfle/[email protected] | ||
with: | ||
access_token: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
|
@@ -97,7 +98,14 @@ jobs: | |
id: buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Check if there are acceptance tests | ||
id: check_for_tests | ||
uses: andstor/file-existence-action@v1 | ||
with: | ||
files: "./${{ inputs.image }}/${{ inputs.image }}_spec.rb" | ||
|
||
- name: Build for acceptance test | ||
if: steps.check_for_tests.outputs.files_exist == 'true' | ||
uses: docker/[email protected] | ||
with: | ||
context: ./${{ inputs.image }} | ||
|
@@ -108,18 +116,17 @@ jobs: | |
cache-from: type=gha | ||
cache-to: type=gha,mode=max | ||
platforms: ${{ inputs.platforms }} | ||
if: ${{ inputs.has_acceptance_tests }} | ||
|
||
- name: Set up ruby | ||
uses: ruby/setup-ruby@v1 | ||
with: | ||
bundler-cache: true | ||
if: ${{ inputs.has_acceptance_tests }} | ||
if: steps.check_for_tests.outputs.files_exist == 'true' | ||
- name: Acceptance Tests | ||
env: | ||
DOCKER_IMAGE: "${{ env.TEST_TAG }}" | ||
run: bundle exec rspec ./${{ inputs.image }}/${{ inputs.image }}_spec.rb | ||
if: ${{ inputs.has_acceptance_tests }} | ||
if: steps.check_for_tests.outputs.files_exist == 'true' | ||
|
||
- name: Build and push to ghcr | ||
uses: docker/[email protected] | ||
|
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
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
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
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
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
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
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
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
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
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
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
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
Oops, something went wrong.