Skip to content

Commit

Permalink
Experimenting with passing data between worflows
Browse files Browse the repository at this point in the history
With artifacts
  • Loading branch information
spaceo committed May 15, 2024
1 parent 10f4b9d commit c48b26d
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 58 deletions.
39 changes: 25 additions & 14 deletions .github/workflows/create-cms-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,30 @@ on:
- completed

jobs:
invoke-external-pr-workflow:
debugging:
runs-on: ubuntu-latest
steps:
- name: Debug
run: echo ${{ toJson(github.event.workflow_run) }}
- name: Debug II
run: echo ${{ toJson(github.event.workflow_run.head_repository ) }}
- name: Deploy Stage
uses: fjogeleit/http-request-action@v1
with:
url: 'https://api.github.com/repos/reload/poc-dpl-cms-pr-trigger/dispatches'
method: 'POST'
customHeaders: '{"Accept": "application/vnd.github+json", "Authorization": "Bearer ${{ secrets.CMS_PR_CREATION_PAT }}" }'
data: '{"event_type":"create_pr","client_payload":{"branch":"${{ env.BRANCH_NAME }}", "build_url":"https://github.com/danskernesdigitalebibliotek/dpl-react/releases/download/branch-user-registration-form-v2/dist-user-registration-form-v2.zip"}}'
env:
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
- uses: actions/download-artifact@v4
with:
name: release-info.json
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ github.event.workflow_run.id }}
- name: Display structure of downloaded files
run: ls -R

# invoke-external-pr-workflow:
# runs-on: ubuntu-latest
# steps:
# - name: Debug
# run: echo ${{ toJson(github.event.workflow_run) }}
# - name: Debug II
# run: echo ${{ toJson(github.event.workflow_run.head_repository ) }}
# - name: Deploy Stage
# uses: fjogeleit/http-request-action@v1
# with:
# url: 'https://api.github.com/repos/reload/poc-dpl-cms-pr-trigger/dispatches'
# method: 'POST'
# customHeaders: '{"Accept": "application/vnd.github+json", "Authorization": "Bearer ${{ secrets.CMS_PR_CREATION_PAT }}" }'
# data: '{"event_type":"create_pr","client_payload":{"branch":"${{ env.BRANCH_NAME }}", "build_url":"https://github.com/danskernesdigitalebibliotek/dpl-react/releases/download/branch-user-registration-form-v2/dist-user-registration-form-v2.zip"}}'
# env:
# BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
100 changes: 56 additions & 44 deletions .github/workflows/create-release-on-branch-changes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,58 +30,70 @@ jobs:
echo "DIST_FILENAME=dist-${RELEASE_BRANCH_SLUGGED}.zip" >> "$GITHUB_ENV"
# Checkout the HEAD of the PR branch to get the latest commit message.
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Get release description
run: |
echo "RELEASE_DESCRIPTION=$(git show -s --format=%s)" >> "$GITHUB_ENV"
# - uses: actions/checkout@v4
# with:
# ref: ${{ github.event.pull_request.head.sha }}
# - name: Get release description
# run: |
# echo "RELEASE_DESCRIPTION=$(git show -s --format=%s)" >> "$GITHUB_ENV"

- uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'yarn'
registry-url: 'https://npm.pkg.github.com'
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# - uses: actions/checkout@v4
# - name: Setup Node
# uses: actions/setup-node@v4
# with:
# node-version-file: '.nvmrc'
# cache: 'yarn'
# registry-url: 'https://npm.pkg.github.com'
# env:
# NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Install Dependencies
run: yarn install --frozen-lockfile
# - name: Install Dependencies
# run: yarn install --frozen-lockfile

- name: Build artifacts
run: yarn build
env:
VERSION_FILE_NAME: ${{ github.repository }}
VERSION_FILE_VERSION: ${{ env.BUILD_VERSION }}
# - name: Build artifacts
# run: yarn build
# env:
# VERSION_FILE_NAME: ${{ github.repository }}
# VERSION_FILE_VERSION: ${{ env.BUILD_VERSION }}

- name: Zip project
run: |
zip -r -j ${{ env.DIST_FILENAME }} dist/
# - name: Zip project
# run: |
# zip -r -j ${{ env.DIST_FILENAME }} dist/


- name: Delete existing releases
uses: dev-drprasad/[email protected]
with:
tag_name: ${{ env.TAG_NAME }}
github_token: ${{ secrets.GITHUB_TOKEN }}
# - name: Delete existing releases
# uses: dev-drprasad/[email protected]
# with:
# tag_name: ${{ env.TAG_NAME }}
# github_token: ${{ secrets.GITHUB_TOKEN }}


- name: Create or update tag
uses: EndBug/[email protected]
with:
ref: ${{ env.TAG_NAME }}
# - name: Create or update tag
# uses: EndBug/[email protected]
# with:
# ref: ${{ env.TAG_NAME }}

- name: Create release
id: create-release
uses: softprops/action-gh-release@v2
with:
target_commitish: ${{ env.RELEASE_SHA }}
tag_name: ${{ env.TAG_NAME }}
body: ${{ env.RELEASE_DESCRIPTION }}
files: ${{ env.DIST_FILENAME }}
# - name: Create release
# id: create-release
# uses: softprops/action-gh-release@v2
# with:
# target_commitish: ${{ env.RELEASE_SHA }}
# tag_name: ${{ env.TAG_NAME }}
# body: ${{ env.RELEASE_DESCRIPTION }}
# files: ${{ env.DIST_FILENAME }}

- name: Adding summary
- name: Write release information in artifact file
run: |
echo "Release created πŸš€πŸ˜Ž at: ${{ steps.create-release.outputs.url }}" >> $GITHUB_STEP_SUMMARY
printf '{
"release_branch": ${{ env.RELEASE_BRANCH }},
"release_download_url": "https://github.com/reload/poc-dpl-react-pr-trigger/releases/download/${{ env.RELEASE_BRANCH }}/${{ env.DIST_FILENAME }}",
}' >> release-info.json
- uses: actions/upload-artifact@v3
with:
name: release-info.json
path: ./

# - name: Adding summary
# run: |
# echo "Release created πŸš€πŸ˜Ž at: ${{ steps.create-release.outputs.url }}" >> $GITHUB_STEP_SUMMARY

0 comments on commit c48b26d

Please sign in to comment.