Merge pull request #59 from WyriHaximus/8.4.0RC1-to-8.4.0RC3 #151
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: Continuous Integration | |
env: | |
DOCKER_IMAGE: wyrihaximusgithubactions/supported-php-versions | |
DOCKER_BUILDKIT: 1 | |
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
jobs: | |
generate-ref: | |
name: Generate Ref | |
runs-on: ubuntu-latest | |
outputs: | |
REF: ${{ steps.generate-ref.outputs.ref }} | |
steps: | |
- uses: actions/checkout@v4 | |
- id: generate-ref | |
name: Generate Ref | |
run: | | |
if [ "${{ github.event_name }}" == "pull_request" ] ; then | |
ref=$(php -r "echo str_replace('/', '-SLASH-', '${{ github.event.pull_request.head.ref }}');") | |
echo "$ref" | |
printf "::set-output name=ref::%s" $ref | |
exit 0 | |
fi | |
echo "${GITHUB_REF##*/}" | |
echo "::set-output name=ref::${GITHUB_REF##*/}" | |
lint-dockerfile: | |
name: Lint Dockerfile | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Lint Dockerfile | |
uses: docker://hadolint/hadolint:latest-debian | |
with: | |
entrypoint: hadolint | |
args: Dockerfile-build | |
fetch-versions: | |
name: Fetch Versions | |
needs: | |
- lint-dockerfile | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Fetch Versions | |
uses: ./ | |
id: versions | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Show Versions | |
run: echo "${VERSIONS}" | |
env: | |
VERSIONS: ${{ steps.versions.outputs.versions }} | |
- name: Fetch Versions including upcoming releases | |
uses: ./ | |
id: versionsincludingupcomingreleases | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upcomingReleases: true | |
- name: Show Versions including upcoming releases | |
run: echo "${VERSIONS}" | |
env: | |
VERSIONS: ${{ steps.versionsincludingupcomingreleases.outputs.versions }} | |
build-docker-image: | |
name: Build Docker image | |
needs: | |
- fetch-versions | |
- generate-ref | |
- lint-dockerfile | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- run: docker version | |
- run: docker images | |
- run: docker build --no-cache -t $(echo "${DOCKER_IMAGE}:${REF}" | tr '[:upper:]' '[:lower:]') . -f Dockerfile-build | |
env: | |
REF: ${{ needs.generate-ref.outputs.ref }} | |
- run: docker tag $(echo "${DOCKER_IMAGE}:${REF}" | tr '[:upper:]' '[:lower:]') "${DOCKER_IMAGE}:sha-${GITHUB_SHA}" | |
env: | |
REF: ${{ needs.generate-ref.outputs.ref }} | |
- run: docker run -v /tmp/trivy:/var/lib/trivy -v /var/run/docker.sock:/var/run/docker.sock -t aquasec/trivy:latest --cache-dir /var/lib/trivy image --exit-code 1 --no-progress --format table $(echo "${DOCKER_IMAGE}:${REF}" | tr '[:upper:]' '[:lower:]') | |
env: | |
REF: ${{ needs.generate-ref.outputs.ref }} | |
- run: docker images | |
- name: Login to Docker Hub | |
if: contains(github.ref, 'dependabot') == false | |
run: | | |
echo "${{ secrets.HUB_PASSCODE }}" | \ | |
docker login \ | |
--username "${{ secrets.HUB_USERNAME }}" \ | |
--password-stdin | |
- name: Push branch image to Docker Hub | |
if: contains(github.ref, 'dependabot') == false | |
run: docker push $(echo "${DOCKER_IMAGE}:${REF}" | tr '[:upper:]' '[:lower:]') | |
env: | |
REF: ${{ needs.generate-ref.outputs.ref }} | |
- name: Push commit sha image to Docker Hub | |
if: contains(github.ref, 'dependabot') == false | |
run: docker push "${DOCKER_IMAGE}:sha-${GITHUB_SHA}" |