Add action to push screenshots to conda store #8
Workflow file for this run
This file contains 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
# This workflow collects screenshots which have stored as artifacts in test.yml | |
# and opens a PR on conda-store to update the docs. | |
# | |
# There are two ways to trigger this workflow: | |
# 1. Trigger by adding the `update_screenshots` label. | |
# The workflow will run immediately after you add the label. It is | |
# also expecting artifacts which have been generated in test.yml. | |
# Therefore, this cannot be triggered until test.yml is complete. | |
# 2. Trigger by workflow dispatch. | |
# Specify the PR number with the artifacts you'd like to use. | |
# Again, the test.yml workflow must be complete. | |
# | |
# If a PR has already been opened on the conda-store repo from this | |
# action, a rerun of this action will attempt to update the PR, not | |
# create a new one. | |
name: Push screenshots to conda-store docs | |
on: | |
pull_request: | |
types: [labeled] | |
workflow_dispatch: | |
inputs: | |
pr_number: | |
description: "PR Number with screenshots to push" | |
required: true | |
jobs: | |
update_screenshots: | |
name: "update_screenshots" | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
shell: bash -el {0} | |
if: ${{ github.event.label.name == 'update_screenshots' && github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch' }} | |
steps: | |
- name: "Checkout the conda-store repository 🛎" | |
uses: actions/checkout@v4 | |
with: | |
path: conda-store-repo | |
repository: 'conda-incubator/conda-store' | |
- name: Use this PR number or the one specified in workflow dispatch | |
run: | | |
if [[ ${{ github.event_name == 'workflow_dispatch' }} == true ]]; then | |
my_variable=${{ inputs.pr_number }} | |
else | |
PR_NUMBER=${{github.event.pull_request.number}} | |
fi | |
echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_ENV | |
- name: Download artifact images - will fail if artifact doesn't exist yet | |
id: download-artifact | |
uses: dawidd6/action-download-artifact@v3 | |
with: | |
# Optional, GitHub token, a Personal Access Token with `public_repo` scope if needed | |
# Required, if the artifact is from a different repo | |
# Required, if the repo is private a Personal Access Token with `repo` scope is needed or GitHub token in a job where the permissions `action` scope set to `read` | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
# workflow file name from which to get the artifact | |
workflow: test.yml | |
# PR from which to get the artifact | |
pr: ${{ env.PR_NUMBER }} | |
# how to exit the action if no artifact is found | |
if_no_artifact_found: fail | |
- name: "ls" | |
run: | | |
ls | |
pwd | |
ls conda-store-repo | |
- name: "Copy images to other repo" | |
run: | | |
cd conda-store-repo | |
cp ../playwright-tests/*.png docusaurus-docs/conda-store-ui/images/. | |
git config user.name ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com> | |
git config user.email '[email protected]' | |
git add -A | |
git commit -m "commit all changes" | |
- name: "Create PR on conda-store with updated screenshots" | |
uses: peter-evans/create-pull-request@v5 | |
with: | |
token: ${{ secrets.PAT }} | |
path: conda-store-repo | |
commit-message: Update screenshots | |
committer: GitHub <[email protected]> | |
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com> | |
branch: update_screenshots | |
delete-branch: true | |
title: '[AUTO] Update screenshots' | |
body: | | |
Update screenshots | |
- Updated with the latest images from playwright generated in PR ${{ env.PR_NUMBER }} | |
- Auto-generated by [create-pull-request][1] | |
[1]: https://github.com/peter-evans/create-pull-request |