From 24c77253d84fc0dabf7357e0ed1a769f81056fad Mon Sep 17 00:00:00 2001 From: Drashti Ladva Date: Mon, 2 Jun 2025 12:13:16 +0530 Subject: [PATCH 1/4] Create artifacts.yaml --- .github/workflows/artifacts.yaml | 57 ++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 .github/workflows/artifacts.yaml diff --git a/.github/workflows/artifacts.yaml b/.github/workflows/artifacts.yaml new file mode 100644 index 0000000..3d54d06 --- /dev/null +++ b/.github/workflows/artifacts.yaml @@ -0,0 +1,57 @@ +name: Math Artifact Demo + +# ✅ Trigger this workflow on pull requests to the main branch +on: + pull_request: + branches: [main] + +jobs: + job_1: + name: Add 3 and 7 (Ubuntu) + runs-on: ubuntu-latest + steps: + - name: Perform addition + run: echo $((3 + 7)) > math-homework.txt + + - name: Upload math result (homework_pre) + uses: actions/upload-artifact@v4 + with: + name: homework_pre + path: math-homework.txt + + job_2: + name: Multiply by 9 (Windows) + needs: job_1 + runs-on: windows-latest + steps: + - name: Download homework_pre + uses: actions/download-artifact@v4 + with: + name: homework_pre + + - name: Multiply result by 9 + shell: bash + run: | + value=$(cat math-homework.txt) + echo $((value * 9)) > math-homework.txt + + - name: Upload final result (homework_final) + uses: actions/upload-artifact@v4 + with: + name: homework_final + path: math-homework.txt + + job_3: + name: Show final result (macOS) + needs: job_2 + runs-on: macos-latest + steps: + - name: Download homework_final + uses: actions/download-artifact@v4 + with: + name: homework_final + + - name: Print final result + run: | + result=$(cat math-homework.txt) + echo " The final math result is: $result" From 1600bbbf5356ce3da2aa364713a7f05bbc74e025 Mon Sep 17 00:00:00 2001 From: Drashti Ladva Date: Mon, 2 Jun 2025 12:14:07 +0530 Subject: [PATCH 2/4] Update artifacts.yaml --- .github/workflows/artifacts.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/artifacts.yaml b/.github/workflows/artifacts.yaml index 3d54d06..683a3f8 100644 --- a/.github/workflows/artifacts.yaml +++ b/.github/workflows/artifacts.yaml @@ -3,7 +3,8 @@ name: Math Artifact Demo # ✅ Trigger this workflow on pull requests to the main branch on: pull_request: - branches: [main] + branches: + - main jobs: job_1: From f0f7b4e8724061ae2e7d2672eb6452fb97754942 Mon Sep 17 00:00:00 2001 From: Drashti Ladva Date: Mon, 2 Jun 2025 12:14:57 +0530 Subject: [PATCH 3/4] Update artifacts.yaml --- .github/workflows/artifacts.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/artifacts.yaml b/.github/workflows/artifacts.yaml index 683a3f8..0a225f8 100644 --- a/.github/workflows/artifacts.yaml +++ b/.github/workflows/artifacts.yaml @@ -1,10 +1,9 @@ name: Math Artifact Demo -# ✅ Trigger this workflow on pull requests to the main branch on: pull_request: branches: - - main + - master jobs: job_1: From 44cc932c4dd7208f3a55e1fd9af3ae9acd8b7f28 Mon Sep 17 00:00:00 2001 From: Drashti Ladva Date: Mon, 2 Jun 2025 12:23:08 +0530 Subject: [PATCH 4/4] Update artifacts.yaml --- .github/workflows/artifacts.yaml | 41 +++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/.github/workflows/artifacts.yaml b/.github/workflows/artifacts.yaml index 0a225f8..4226fec 100644 --- a/.github/workflows/artifacts.yaml +++ b/.github/workflows/artifacts.yaml @@ -1,57 +1,76 @@ -name: Math Artifact Demo +name: Math Artifact with Digest on: pull_request: - branches: - - master + branches: master + jobs: job_1: name: Add 3 and 7 (Ubuntu) runs-on: ubuntu-latest + outputs: + digest: ${{ steps.upload.outputs.digest }} steps: - - name: Perform addition + - name: Add 3 + 7 run: echo $((3 + 7)) > math-homework.txt - - name: Upload math result (homework_pre) + - name: Upload artifact (homework_pre) + id: upload uses: actions/upload-artifact@v4 with: name: homework_pre path: math-homework.txt + - name: Show uploaded digest + run: echo "Uploaded Digest ${{ steps.upload.outputs.digest }}" + job_2: name: Multiply by 9 (Windows) needs: job_1 runs-on: windows-latest steps: - - name: Download homework_pre + - name: Download artifact uses: actions/download-artifact@v4 with: name: homework_pre - - name: Multiply result by 9 + - name: Show original file content + shell: bash + run: cat math-homework.txt + + - name: Multiply by 9 shell: bash run: | value=$(cat math-homework.txt) echo $((value * 9)) > math-homework.txt - name: Upload final result (homework_final) + id: upload uses: actions/upload-artifact@v4 with: name: homework_final path: math-homework.txt + - name: Show final digest + run: echo "Uploaded Final Digest ${{ steps.upload.outputs.digest }}" + job_3: - name: Show final result (macOS) + name: Display final result (macOS) needs: job_2 runs-on: macos-latest steps: - - name: Download homework_final + - name: Download final artifact uses: actions/download-artifact@v4 with: name: homework_final - - name: Print final result + - name: Display result run: | result=$(cat math-homework.txt) - echo " The final math result is: $result" + echo "Final result is: $result" + + - name: (Optional) Manual SHA256 digest + run: | + echo "Manual SHA256:" + shasum -a 256 math-homework.txt