-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7d07da6
commit 6420dd3
Showing
3 changed files
with
94 additions
and
110 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,94 @@ | ||
name: Docker | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
paths: | ||
- "Dockerfile" | ||
- ".github/workflows/docker.yml" | ||
pull_request: | ||
branches: | ||
- master | ||
paths: | ||
- "Dockerfile" | ||
- ".github/workflows/docker.yml" | ||
|
||
env: | ||
IMAGE_NAME: hatamiarash7/webhook | ||
GITHUB_IMAGE_NAME: ${{ github.repository }}/webhook | ||
|
||
jobs: | ||
test: | ||
name: Test | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Cancel previous workflow | ||
uses: styfle/[email protected] | ||
with: | ||
access_token: ${{ github.token }} | ||
|
||
- uses: actions/checkout@v3 | ||
|
||
- name: Build image | ||
run: docker build -t test . | ||
|
||
- name: Trivy | ||
uses: aquasecurity/trivy-action@master | ||
with: | ||
image-ref: test | ||
format: "template" | ||
template: "@/contrib/sarif.tpl" | ||
output: "trivy-results.sarif" | ||
|
||
- name: Upload Trivy scan results | ||
uses: github/codeql-action/upload-sarif@v2 | ||
with: | ||
sarif_file: "trivy-results.sarif" | ||
|
||
- name: Lint Docker files | ||
uses: hadolint/[email protected] | ||
with: | ||
verbose: true | ||
ignore: "DL3008,DL3025" | ||
failure-threshold: "error" | ||
|
||
push: | ||
name: Deploy | ||
needs: test | ||
runs-on: ubuntu-latest | ||
if: github.event_name != 'pull_request' | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Create image name | ||
id: github-image | ||
uses: ASzc/change-string-case-action@v2 | ||
with: | ||
string: ghcr.io/${{ env.GITHUB_IMAGE_NAME }} | ||
|
||
- name: Get Current Date | ||
id: date | ||
run: echo "::set-output name=date::$(date +'%Y-%m-%d')" | ||
|
||
- name: Build image | ||
run: > | ||
docker build | ||
-t ${{ env.IMAGE_NAME }} | ||
-t ${{ steps.github-image.outputs.lowercase }} | ||
--build-arg DATE_CREATED=${{ steps.date.outputs.date }} | ||
-f Dockerfile | ||
. | ||
- name: Push to Dockerhub | ||
run: | | ||
docker login -u hatamiarash7 -p "${{ secrets.DOCKERHUB_TOKEN }}" | ||
docker push ${{ env.IMAGE_NAME }} | ||
- name: Push to Github | ||
run: | | ||
docker login -u hatamiarash7 -p "${{ secrets.GB_TOKEN }}" ghcr.io | ||
docker push ${{ steps.github-image.outputs.lowercase }} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.