diff --git a/.github/actions/set-env-vars/action.yml b/.github/actions/set-env-vars/action.yml new file mode 100644 index 0000000..2329cb0 --- /dev/null +++ b/.github/actions/set-env-vars/action.yml @@ -0,0 +1,24 @@ +name: "Set Environment Variables" +description: "Set environment variables for the workflow run" + +outputs: + event_name: + description: "GitHub event name" + value: ${{ steps.set-vars.outputs.event_name }} + ref_name: + description: "GitHub ref name" + value: ${{ steps.set-vars.outputs.ref_name }} + repo_name: + description: "GitHub repository name" + value: ${{ steps.set-vars.outputs.repo_name }} + +runs: + using: "composite" + steps: + - name: Set env vars + id: set-vars + shell: bash + run: | + echo "event_name=${{ github.event_name }}" >> "$GITHUB_OUTPUT" + echo "ref_name=${{ github.ref }}" >> "$GITHUB_OUTPUT" + echo "repo_name=${{ github.repository }}" >> "$GITHUB_OUTPUT" diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml new file mode 100644 index 0000000..151103a --- /dev/null +++ b/.github/workflows/cd.yml @@ -0,0 +1,57 @@ +name: Test Workflow +on: + push: + branches: + - dev + - main + +jobs: + set-env-vars: + runs-on: ubuntu-latest + container: + image: cgr.dev/chainguard/node:latest + options: --user root + outputs: + event_name: ${{ steps.set-env-vars.outputs.event_name }} + ref_name: ${{ steps.set-env-vars.outputs.ref_name }} + repo_name: ${{ steps.set-env-vars.outputs.repo_name }} + steps: + - name: Check user + run: whoami + - name: Checkout code + uses: actions/checkout@v4 + - name: Set Github Environment Variables + id: set-env-vars + uses: ./.github/actions/set-env-vars + + print-env-vars: + runs-on: ubuntu-latest + needs: set-env-vars + steps: + - name: Check if dev branch + if: "${{ needs.set-env-vars.outputs.ref_name == 'refs/heads/dev'}}" + run: echo "This is the dev branch" + - name: Print env vars + run: | + echo "Event Name: ${{ needs.set-env-vars.outputs.event_name }}" + echo "Ref Name: ${{ needs.set-env-vars.outputs.ref_name }}" + echo "Repo Name: ${{ needs.set-env-vars.outputs.repo_name }}" + + job1: + runs-on: ubuntu-latest + outputs: + output1: ${{ steps.step1.outputs.test }} + output2: ${{ steps.step2.outputs.test }} + steps: + - id: step1 + run: echo "test=hello" >> "$GITHUB_OUTPUT" + - id: step2 + run: echo "test=world" >> "$GITHUB_OUTPUT" + job2: + runs-on: windows-latest + needs: job1 + steps: + - env: + OUTPUT1: ${{needs.job1.outputs.output1}} + OUTPUT2: ${{needs.job1.outputs.output2}} + run: echo "$OUTPUT1 $OUTPUT2" \ No newline at end of file diff --git a/.github/workflows/d2p.yml b/.github/workflows/d2p.yml index a2908dc..ec1727b 100644 --- a/.github/workflows/d2p.yml +++ b/.github/workflows/d2p.yml @@ -19,4 +19,9 @@ jobs: with: branch: prod-promotion title: d2p + body: | + Merging & deploying instructions: + - [Some link][1] + + [1]: https://www.google.com labels: Test Label 🌴, bug