diff --git a/.github/workflows/combine_appfilter.py b/.github/workflows/combine_appfilter.py index c48ed94d65..d2fa3d920c 100644 --- a/.github/workflows/combine_appfilter.py +++ b/.github/workflows/combine_appfilter.py @@ -95,7 +95,7 @@ def combine_all_appfilters(): # Check if the pull request has an appfilter.xml file for file in files: - print(f"File: {file.filename}") + #print(f"File: {file.filename}") if file.filename == 'newicons/appfilter.xml': print(f"Found appfilter.xml: {file.filename}") try: @@ -117,55 +117,5 @@ def combine_all_appfilters(): continue print("Combined appfilter.xml from all pull requests.") - - # Try to get the content of the existing combined_appfilter.xml file - try: - existing_file = repo.get_contents('docs/assets/combined_appfilter.xml', ref=branchName) - print(existing_file) # Debugging statement - if existing_file: - try: - response = requests.get(existing_file.download_url) - if response.status_code == 200: - existing_content = response.content.decode('utf-8') - existing_sha1 = calculate_sha1(existing_content) - existing_sha = existing_file.sha - except Exception as e: - print(f"Error parsing XML from URL: {e}") - return None - else: - print("The existing_file is None.") - existing_content = None - existing_sha1 = None - except Exception as e: - print(f"No existing combined_appfilter.xml file found. {e}") - existing_content = None - existing_sha1 = None - - - # Read the content of the new combined file - with open('combined_appfilter.xml', 'r') as combined_file: - new_content = combined_file.read() - - # Calculate the SHA-1 hash of the new content - new_sha1 = calculate_sha1(new_content) - - print(f"Existing SHA-1: {existing_sha1}") - print(f"New SHA-1: {new_sha1}") - - # Check if the new content is different from the existing content or if the file doesn't exist - if existing_sha1 is None or new_sha1 != existing_sha1: - try: - if existing_content is None: - # Create the combined_appfilter.xml file in the repository - repo.create_file('docs/assets/combined_appfilter.xml', 'Created combined appfilter.xml from pull requests', new_content, branch=branchName) - print("Created combined_appfilter.xml in the repository.") - else: - # Update the combined_appfilter.xml file in the repository - repo.update_file('docs/assets/combined_appfilter.xml', 'Updated combined appfilter.xml from pull requests', new_content, existing_sha, branch=branchName) - print("Updated combined_appfilter.xml in the repository.") - except Exception as e: - print(f"Error updating/creating combined_appfilter.xml in the repository: {e}") - else: - print("No changes detected in combined_appfilter.xml.") combine_all_appfilters() \ No newline at end of file diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f564a5e240..baf3a38a4c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,22 +1,39 @@ -name: Parse and Combine Pull Request +name: Combine Appfilter and Build Pages on: pull_request_target: types: [opened, synchronize, reopened] branches: - main + paths: + - 'newicons/appfilter.xml' + push: + branches: ["Arcticons-Pages"] + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages +permissions: + contents: read + pages: write + id-token: write + concurrency: - group: 'appfilter' + group: 'pages' cancel-in-progress: true jobs: parse_and_combine: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} runs-on: ubuntu-latest steps: - name: Checkout Repository uses: actions/checkout@v4 + with: + ref: ArcticonsPages - name: Set up Python uses: actions/setup-python@v5 @@ -29,9 +46,15 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: python .github/workflows/combine_appfilter.py - + - name: Move combinded Appfilter + run: mv combined_appfilter.xml docs/assets/combined_appfilter.xml + - name: Setup Pages + uses: actions/configure-pages@v5 - name: Upload artifact - uses: actions/upload-artifact@v4 + uses: actions/upload-pages-artifact@v3 with: - path: '.' - + # Upload docs folder + path: 'docs' + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 \ No newline at end of file