forked from nfelger/achill
-
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.
Create new action for testing environment
- Loading branch information
1 parent
64f0aab
commit ac69ff8
Showing
1 changed file
with
105 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,105 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
branches: [main] | ||
# Allow to run this workflow manually | ||
workflow_dispatch: | ||
|
||
env: | ||
REGISTRY: ghcr.io | ||
IMAGE_NAME: ${{ github.repository }} | ||
|
||
jobs: | ||
test-app: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 10 | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Setup Node | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: "16.13.0" | ||
cache: "npm" | ||
|
||
- run: npm install | ||
|
||
- name: Set up playwright | ||
run: npx playwright install | ||
|
||
- name: Check format | ||
run: npm run lint | ||
|
||
- name: Run unit tests | ||
run: npm test | ||
|
||
build-push-image: | ||
needs: [test-app] | ||
if: github.ref == 'refs/heads/main' | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 10 | ||
permissions: | ||
security-events: write | ||
packages: write | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Build an image from Dockerfile | ||
run: | | ||
docker build -t ${{ env.IMAGE_NAME }}:testing . | ||
- name: Run Trivy vulnerability scanner | ||
uses: aquasecurity/trivy-action@master | ||
with: | ||
image-ref: "${{ env.IMAGE_NAME }}:testing" | ||
format: "template" | ||
template: "@/contrib/sarif.tpl" | ||
output: "trivy-results.sarif" | ||
ignore-unfixed: true | ||
vuln-type: "os,library" | ||
severity: "CRITICAL,HIGH" | ||
|
||
- 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 container registry | ||
uses: docker/login-action@v1 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Push image | ||
run: | | ||
docker tag ${{ env.IMAGE_NAME }}:testing ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | ||
docker tag ${{ env.IMAGE_NAME }}:testing ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:testing | ||
docker push --all-tags ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | ||
deploy: | ||
needs: [build-push-image] | ||
if: github.ref !== 'refs/heads/main' | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 10 | ||
permissions: | ||
packages: read | ||
environment: staging | ||
steps: | ||
- name: Deploy new image | ||
uses: digitalservicebund/github-actions/argocd-deploy@9b15fba0ce0e874d9af5be33ebeea7d476f808d0 | ||
with: | ||
environment: staging | ||
version: testing | ||
deploying_repo: achill | ||
infra_repo: achill-infra | ||
deploy_key: ${{ secrets.DEPLOY_KEY }} | ||
app: achill-staging | ||
argocd_pipeline_password: ${{ secrets.ARGOCD_PIPELINE_PASSWORD }} | ||
argocd_server: ${{ secrets.ARGOCD_SERVER }} | ||
argocd_sync_timeout: 300 |