mirror of
https://github.com/mashirozx/docker-php-nginx.git
synced 2024-11-22 23:08:15 +08:00
Migrate builds to GitHub Actions
This commit is contained in:
parent
a58dccfd64
commit
16df3f80fc
58
.github/workflows/deploy.yaml
vendored
Normal file
58
.github/workflows/deploy.yaml
vendored
Normal file
@ -0,0 +1,58 @@
|
||||
name: Test & build Docker image
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
pull_request:
|
||||
|
||||
env:
|
||||
IMAGE_NAME: trafex/php-nginx
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Build image
|
||||
run: |-
|
||||
docker build -t $IMAGE_NAME .
|
||||
docker tag $IMAGE_NAME:latest $IMAGE_NAME:${{ github.sha }}
|
||||
|
||||
- name: Smoke test image
|
||||
run: |-
|
||||
docker-compose -f docker-compose.test.yml up -d app
|
||||
sleep 2
|
||||
docker-compose -f docker-compose.test.yml run sut
|
||||
|
||||
- name: Run Trivy vulnerability scanner
|
||||
uses: aquasecurity/trivy-action@master
|
||||
with:
|
||||
image-ref: '${{ env.IMAGE_NAME }}:${{ github.sha }}'
|
||||
format: 'template'
|
||||
template: '@/contrib/sarif.tpl'
|
||||
output: 'trivy-results.sarif'
|
||||
|
||||
- name: Upload Trivy scan results to GitHub Security tab
|
||||
uses: github/codeql-action/upload-sarif@v1
|
||||
with:
|
||||
sarif_file: 'trivy-results.sarif'
|
||||
|
||||
- name: Login to Docker Hub
|
||||
if: github.ref == 'refs/heads/master' && github.event_name == 'push'
|
||||
uses: docker/login-action@v1
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
- name: Push latest image
|
||||
if: github.ref == 'refs/heads/master' && github.event_name == 'push'
|
||||
run: |-
|
||||
docker push $IMAGE_NAME:latest
|
||||
|
||||
- name: Push tagged image
|
||||
if: contains(github.ref, 'refs/tags/v')
|
||||
run: |-
|
||||
docker push $IMAGE_NAME:$GITHUB_TAG
|
Loading…
Reference in New Issue
Block a user