diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..0eb1f9d6 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,26 @@ +name: CICD PIPELINE + +on: push + +jobs: + first_job: + runs-on: ubuntu-latest + steps: + - name: Checkout Repo + uses: actions/checkout@v4 + + - name: List and Read Files + run: | + echo "This is a pipeline for Netflix clone App" + ls -lrta + cat README.md + + - name: Generate ASCII ArtWork + run: cowsay -f dragon "Run for cover, I am a Dragon....RAWR" >> dragon.txt + + + # - name: List Files + # run: ls + + # - name: Read file + # run: cat README.md diff --git a/.github/workflows/context-testing.yml b/.github/workflows/context-testing.yml new file mode 100644 index 00000000..cbc8465c --- /dev/null +++ b/.github/workflows/context-testing.yml @@ -0,0 +1,27 @@ +name: Context testing +on: push + +jobs: + dump_contexts_to_log: + runs-on: ubuntu-latest + steps: + - name: Dump GitHub context + env: + GITHUB_CONTEXT: ${{ toJson(github) }} + run: echo "$GITHUB_CONTEXT" + - name: Dump job context + env: + JOB_CONTEXT: ${{ toJson(job) }} + run: echo "$JOB_CONTEXT" + - name: Dump steps context + env: + STEPS_CONTEXT: ${{ toJson(steps) }} + run: echo "$STEPS_CONTEXT" + - name: Dump runner context + env: + RUNNER_CONTEXT: ${{ toJson(runner) }} + run: echo "$RUNNER_CONTEXT" + - name: Dump secret context + env: + SECRET_CONTEXT: ${{ toJson(secrets) }} + run: echo "$SECRET_CONTEXT" \ No newline at end of file diff --git a/.github/workflows/generate-ascii.yml b/.github/workflows/generate-ascii.yml new file mode 100644 index 00000000..10c65476 --- /dev/null +++ b/.github/workflows/generate-ascii.yml @@ -0,0 +1,74 @@ +name: Generate ASCII Artwork + +on: + push + +jobs: + build_job_1: + runs-on: ubuntu-latest + steps: + - name: Install Cowsay Program + run: sudo apt-get install cowsay -y + + - name: Execute Cowsay CMD + run: cowsay -f dragon "Run for cover, I am a Dragon....RAWR" >> dragon.txt + + - name: Upload Dragon Text File + uses: actions/upload-artifact@v4 + with: + name: dragon-text-file + path: dragon.txt + + test_job_2: + needs: build_job_1 # use needs to specify a job which the current job depends on + runs-on: ubuntu-latest + steps: + - name: Download Dragon Text File + uses: actions/download-artifact@v4 + with: + name: dragon-text-file + # we don't need to specify a part for the download + - name: Test File Exists + run: grep -i "dragon" dragon.txt + + deploy_job_3: + needs: [test_job_2] # You can define the jobs it needs as an array if they are more than one, I only used the array here for example and as part of my documentation + runs-on: ubuntu-latest + steps: + - name: Download Dragon Text File + uses: actions/download-artifact@v4 + with: + name: dragon-text-file + # it is optional to specify a part for the download + + - name: Read File + run: cat dragon.txt + + - name: Deploy + run: echo Deploy ... ... ... ... + + + # - name: Checkout Repo + # uses: actions/checkout@v4 + + # - name: List Repo Files + # run: ls -ltra + + # - name: Executing Shell Script + # run: | + # chmod +x script.sh + # ./script.sh + + # - name: Install Cowsay Program + # run: sudo apt-get install cowsay -y + + # - name: Execute Cowsay CMD + # run: cowsay -f dragon "Run for cover, I am a Dragon....RAWR" >> dragon.txt + + # - name: Check if Test File Exists + # run: grep -i "dragon" dragon.txt + + # - name: Read file + # run: cat dragon.txt + + diff --git a/.github/workflows/matrix-configuration.yml b/.github/workflows/matrix-configuration.yml new file mode 100644 index 00000000..dd306c9c --- /dev/null +++ b/.github/workflows/matrix-configuration.yml @@ -0,0 +1,28 @@ +name: Matrix Configuration + +on: + push: + workflow_dispatch: + +jobs: + deploy: + strategy: + fail-fast: false #disable fail-fast using false. This prevents GitHub from cancelling any job in prgress if any job in the matrix fails + max-parallel: 2 # control the number of jobs that can run parrelling by setting it to 2 parrallel jobs + matrix: + os: [ubuntu-latest, ubuntu-20.04, windows-latest] + images: [hello-world, alpine] + # This is supposed to run 6 jobs, but will not run up to 6 because of the exclude operation + exclude: + - images: alpine + os: windows-latest + include: + - images: amd64/alpine + os: ubuntu-20.04 + runs-on: ${{ matrix.os }} + steps: + - name: Echo Docker Details + run: docker info + + - name: Run Image on ${{ matrix.os }} + run: docker run ${{ matrix.images }} \ No newline at end of file diff --git a/.github/workflows/variable-secrets.yml b/.github/workflows/variable-secrets.yml new file mode 100644 index 00000000..e9add431 --- /dev/null +++ b/.github/workflows/variable-secrets.yml @@ -0,0 +1,176 @@ +# name: Exploring variables and secrets + +# on: +# push + +# #Environment variable defined at the workflow level + +# env: +# CONTAINER_REGISTRY: docker.io +# DOCKER_USERNAME: siddharth1 +# IMAGE_NAME: github-actions-nginx + +# jobs: + +# docker: +# runs-on: ubuntu-latest +# steps: +# - name: Docker Build +# run: docker build -t docker.io/dockerusername/imageName:latest + +# - name: Docker Login +# run: docker login --username=dockerUsername --pasword=s3cUrePaSsw0rd + +# - name: Docker Publish +# run: docker push docker.io/dockerusername/imageName:latest + + +# deploy: +# needs: docker +# runs-on: ubuntu-latest +# steps: +# - name: Docker Run +# run: docker run -d -p 8080:80 docker.io/dockerusername/imageName:latest + + +################## environment variables at STEP level ##################### + + # Note it is best to define environment variables at the job level so that they can be reusable in different jobs + + # docker: + # runs-on: ubuntu-latest + # steps: + # - name: Docker Build + # env: + # CONTAINER_REGISTRY: docker.io + # DOCKER_USERNAME: siddharth1 + # IMAGE_NAME: github-actions-nginx + # run: echo docker build -t $CONTAINER_REGISTRY/$DOCKER_USERNAME/$IMAGE_NAME:latest + + # - name: Docker Login + # env: + # DOCKER_PASSWORD: s3cUrePaSsw0rd + # DOCKER_USERNAME: siddharth1 + # run: echo docker login --username=$DOCKER_USERNAME --password=$DOCKER_PASSWORD + + # - name: Docker Publish + # env: # Define environment variables + # CONTAINER_REGISTRY: docker.io + # DOCKER_USERNAME: siddharth1 + # IMAGE_NAME: github-actions-nginx + # run: echo docker push $CONTAINER_REGISTRY/$DOCKER_USERNAME/$IMAGE_NAME:latest + + # deploy: + # needs: docker + # runs-on: ubuntu-latest + # steps: + # - name: Docker Run + # env: + # CONTAINER_REGISTRY: docker.io + # DOCKER_USERNAME: siddharth1 + # IMAGE_NAME: github-actions-nginx + # run: echo docker run -d -p 8080:80 ${{ env.CONTAINER_REGISTRY }}/${{ env.DOCKER_USERNAME}}/${{ env.IMAGE_NAME}}:latest + # # Another way to use environment variables is using curly braces {{env.}} + + +################## environment variables at JOB level ##################### + + # Note it is good to define environment variables at the job level so that they can be reusable in different jobs + + # docker: + # env: + # CONTAINER_REGISTRY: docker.io + # DOCKER_USERNAME: siddharth1 + # IMAGE_NAME: github-actions-nginx + # runs-on: ubuntu-latest + # steps: + # - name: Docker Build + # run: echo docker build -t ${{ env.CONTAINER_REGISTRY }}/${{ env.DOCKER_USERNAME}}/${{ env.IMAGE_NAME}}:latest + + # - name: Docker Login + # env: + # DOCKER_PASSWORD: S3cUrePaSsw0rd + # run: echo docker login --username=$DOCKER_USERNAME --password=$DOCKER_PASSWORD + + # - name: Docker Publish + # run: echo docker push ${{ env.CONTAINER_REGISTRY }}/${{ env.DOCKER_USERNAME}}/${{ env.IMAGE_NAME}}:latest + + + # deploy: + # env: + # CONTAINER_REGISTRY: docker.io + # DOCKER_USERNAME: siddharth1 + # IMAGE_NAME: github-actions-nginx + # needs: docker + # runs-on: ubuntu-latest + # steps: + # - name: Docker Run + # run: docker run -d -p 8080:80 ${{ env.CONTAINER_REGISTRY }}/${{ env.DOCKER_USERNAME}}/${{ env.IMAGE_NAME}}:latest + + +################## environment variables at Workflow level ##################### +# Defining evironment variables at the Workflow level + + # docker: + # runs-on: ubuntu-latest + # steps: + # - name: Docker Build + # run: echo docker build -t ${{ env.CONTAINER_REGISTRY }}/${{ env.DOCKER_USERNAME}}/${{ env.IMAGE_NAME}}:latest + + # - name: Docker Login + # env: + # DOCKER_PASSWORD: S3cUrePaSsw0rd + # run: echo docker login --username=$DOCKER_USERNAME --password=$DOCKER_PASSWORD + + # - name: Docker Publish + # run: echo docker push ${{ env.CONTAINER_REGISTRY }}/${{ env.DOCKER_USERNAME}}/${{ env.IMAGE_NAME}}:latest + + + # deploy: + # needs: docker + # runs-on: ubuntu-latest + # steps: + # - name: Docker Run + # run: docker run -d -p 8080:80 ${{ env.CONTAINER_REGISTRY }}/${{ env.DOCKER_USERNAME}}/${{ env.IMAGE_NAME}}:latest + + +########### environment variables and secrets at the repository level #################### + + name: Exploring Variables and Secrets + + on: + workflow_dispatch: # To manually trigger the workflow + # schedule: + # - cron: '*/1 * * * *' + push: + + env: + CONTAINER_REGISTRY: docker.io + IMAGE_NAME: github-actions-nginx + + jobs: + docker: + runs-on: ubuntu-latest + steps: + - name: Docker Build + run: echo docker build -t ${{ env.CONTAINER_REGISTRY }}/${{ vars.DOCKER_USERNAME }}/$IMAGE_NAME:latest + + - name: Docker Login + run: echo docker login --username=${{ vars.DOCKER_USERNAME }} --password=${{ secrets.DOCKER_PASSWORD }} + + - name: Docker Publish + run: echo docker push $CONTAINER_REGISTRY/${{ vars.DOCKER_USERNAME }}/$IMAGE_NAME:latest + + deploy: + if: github.ref == 'refs/heads/main' #set condition that the deploy job should run only on the main branch + needs: docker + concurrency: + group: production-deployment # set concurrency group + cancel-in-progress: false + runs-on: ubuntu-latest + steps: + - name: Docker Run + timeout-minutes: 1 + run: | + echo docker run -d -p 8080:80 $CONTAINER_REGISTRY/${{ vars.DOCKER_USERNAME }}/$IMAGE_NAME:latest + #sleep 600s \ No newline at end of file diff --git a/.github/workflows/workflow-filters.yml b/.github/workflows/workflow-filters.yml new file mode 100644 index 00000000..508e8caa --- /dev/null +++ b/.github/workflows/workflow-filters.yml @@ -0,0 +1,28 @@ +name: Workflow Filters and Activities + +on: + workflow_dispatch: +# schedule: +# - cron: "*/59 * * * *" + push: + branches: + - main + - '!feature/*' # ignoring pushing to any branch name starting with feature using ! + # branches-ignore: + # - feature/* # feature/add-music, feature/updateImages + # - test/** # test/ui/index, test/checkout/payment/ + + pull_request: + types: + - opened + - closed + paths-ignore: # workflow will only run when a pull request that includes a change on any file other than README.md + - README.md + branches: + - main # configures your workflow to only run on pull requests that target specific branches. + +jobs: + hello: + runs-on: ubuntu-latest + steps: + - run: echo this workflow/job/step is executed for event type - ${{ github.event_name }} \ No newline at end of file diff --git a/script.sh b/script.sh new file mode 100644 index 00000000..fc6c998a --- /dev/null +++ b/script.sh @@ -0,0 +1,6 @@ +#!/bin/bash +sudo apt-get install cowsay -y +cowsay -f dragon "Run for cover, I am a Dragon....RAWR" >> dragon.txt +grep -i "dragon" dragon.txt +cat dragon.txt +ls -ltra