added manual trigger as well #21
This file contains hidden or 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
name: First Workflow | |
on: push | |
env: | |
TOOL: docker | |
CONTAINER_REGISTRY: docker.io | |
jobs: | |
first_job: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Welcome message | |
run: echo 'My First Github Actions Job' | |
- name: Checkout Repo | |
uses: actions/checkout@v4 | |
with: | |
repository: ${{ github.repository }} | |
- name: Read Readme | |
run: cat README.md | |
- name: List Files | |
run: ls | |
- name: Print envs | |
run: printenv | |
- name: Perform multiple actions | |
run: | | |
echo 'Running multiple commands' | |
ls -a | |
- name: Installing cowsay | |
run: sudo apt install cowsay -y | |
- name: Execute cowsay | |
run: | | |
cowsay -f dragon "Hello Yatharth!!" >> drag.txt | |
cat drag.txt | |
- name: Execute shell script | |
run: | | |
chmod +x cowsay-script.sh | |
./cowsay-script.sh | |
- name: Upload files | |
uses: actions/upload-artifact@v4.4.3 | |
with: | |
name: dragon | |
path: drag.txt | |
second_job: | |
runs-on: ubuntu-latest | |
needs: | |
- first_job | |
steps: | |
- name: Welcome message | |
run: echo 'My Second Github Actions Job' | |
- name: Download a Build Artifact | |
uses: actions/download-artifact@v4.1.8 | |
with: | |
name: dragon | |
- name: Check cowsay | |
run: | | |
ls -la | |
cat drag.txt | |
docker_job: | |
runs-on: ubuntu-latest | |
env: | |
DOCKER_REPOSITORY_NAME: yatharth0045 | |
IMAGE_NAME: cowsay | |
IMAGE_VERSION: latest | |
steps: | |
- name: Check docker | |
env: | |
DOCKER_TASK: version | |
run: ${{ env.TOOL }} --$DOCKER_TASK | |
- name: Check containers | |
run: ${{ env.TOOL }} ps | |
- name: Clone repo | |
uses: actions/checkout@v4 | |
- name: Build Docker | |
env: | |
DOCKER_TASK: build | |
run: ${{ env.TOOL }} build -t ${{ env.CONTAINER_REGISTRY }}/${{ env.DOCKER_REPOSITORY_NAME }}/${{ env.IMAGE_NAME }}:${{ env.IMAGE_VERSION }} . | |
- name: Login Docker | |
run: ${{ env.TOOL }} login --username=${{ vars.DOCKER_USERNAME }} --password=${{ secrets.DOCKER_PASSWORD }} | |
- name: Get Docker Secrets | |
run: cat /home/runner/.docker/config.json | |
- name: Docker Publish | |
env: | |
DOCKER_TASK: push | |
run: ${{ env.TOOL }} push ${{ env.CONTAINER_REGISTRY }}/${{ env.DOCKER_REPOSITORY_NAME }}/${{ env.IMAGE_NAME }}:${{ env.IMAGE_VERSION }} |