Add cron in the workflow

Signed-off-by: divyansh42 <diagrawa@redhat.com>
This commit is contained in:
divyansh42 2021-04-01 15:47:52 +05:30
parent 3196e5acb5
commit 52712f56b0
3 changed files with 33 additions and 7 deletions

View file

@ -2,7 +2,13 @@
# is some change in code done to ensure that the changes # is some change in code done to ensure that the changes
# are not buggy and we are getting the desired output. # are not buggy and we are getting the desired output.
name: Build from dockerfile name: Build from dockerfile
on: [push, pull_request, workflow_dispatch] on:
push:
pull_request:
workflow_dispatch:
schedule:
- cron: '0 0 * * *' # every day at midnight
env: env:
IMAGE_NAME: "hello-world" IMAGE_NAME: "hello-world"
@ -25,6 +31,12 @@ jobs:
RUN echo "hello world" RUN echo "hello world"
EOF EOF
# Workaround to fix https://github.com/containers/buildah/issues/3120
- run: |
sudo apt-get install fuse-overlayfs
mkdir -vp ~/.config/containers
printf "[storage.options]\nmount_program=\"/usr/bin/fuse-overlayfs\"" > ~/.config/containers/storage.conf
# Build image using Buildah action # Build image using Buildah action
- name: Build Image - name: Build Image
id: build_image id: build_image

View file

@ -6,6 +6,8 @@ on:
pull_request: pull_request:
paths: paths:
-'**.md' -'**.md'
schedule:
- cron: '0 0 * * *' # every day at midnight
jobs: jobs:
markdown-link-check: markdown-link-check:

View file

@ -2,7 +2,13 @@
# is some change in code done to ensure that the changes # is some change in code done to ensure that the changes
# are not buggy and we are getting the desired output. # are not buggy and we are getting the desired output.
name: Build name: Build
on: [push, pull_request, workflow_dispatch] on:
push:
pull_request:
workflow_dispatch:
schedule:
- cron: '0 0 * * *' # every day at midnight
env: env:
PROJECT_DIR: spring-petclinic PROJECT_DIR: spring-petclinic
IMAGE_NAME: spring-petclinic IMAGE_NAME: spring-petclinic
@ -26,14 +32,14 @@ jobs:
with: with:
repository: "spring-projects/spring-petclinic" repository: "spring-projects/spring-petclinic"
path: ${{ env.PROJECT_DIR }} path: ${{ env.PROJECT_DIR }}
# If none of these files has changed, we assume that the contents of # If none of these files has changed, we assume that the contents of
# .m2/repository can be fetched from the cache. # .m2/repository can be fetched from the cache.
- name: Hash Maven files - name: Hash Maven files
working-directory: ${{ env.PROJECT_DIR }} working-directory: ${{ env.PROJECT_DIR }}
run: | run: |
echo "MVN_HASH=${{ hashFiles('**/pom.xml', '.mvn/**/*', 'mvnw*') }}" >> $GITHUB_ENV echo "MVN_HASH=${{ hashFiles('**/pom.xml', '.mvn/**/*', 'mvnw*') }}" >> $GITHUB_ENV
# Download the m2 repository from the cache to speed up the build. # Download the m2 repository from the cache to speed up the build.
- name: Check for Maven cache - name: Check for Maven cache
id: check-mvn-cache id: check-mvn-cache
@ -52,7 +58,7 @@ jobs:
- name: Maven - name: Maven
working-directory: ${{ env.PROJECT_DIR }} working-directory: ${{ env.PROJECT_DIR }}
run: | run: |
mvn package -ntp -B mvn package -ntp -B
# If there was no cache hit above, store the output into the cache now. # If there was no cache hit above, store the output into the cache now.
- name: Save Maven repo into cache - name: Save Maven repo into cache
@ -61,7 +67,13 @@ jobs:
with: with:
path: ${{ env.MVN_REPO_DIR }} path: ${{ env.MVN_REPO_DIR }}
key: ${{ env.MVN_HASH }} key: ${{ env.MVN_HASH }}
# Workaround to fix https://github.com/containers/buildah/issues/3120
- run: |
sudo apt-get install fuse-overlayfs
mkdir -vp ~/.config/containers
printf "[storage.options]\nmount_program=\"/usr/bin/fuse-overlayfs\"" > ~/.config/containers/storage.conf
# Build image using Buildah action # Build image using Buildah action
- name: Build Image - name: Build Image
id: build_image id: build_image
@ -81,7 +93,7 @@ jobs:
archs: amd64,arm64 archs: amd64,arm64
- name: Echo Outputs - name: Echo Outputs
run: | run: |
echo "Image: ${{ steps.build_image.outputs.image }}" echo "Image: ${{ steps.build_image.outputs.image }}"
echo "Tags: ${{ steps.build_image.outputs.tags }}" echo "Tags: ${{ steps.build_image.outputs.tags }}"