Update main.yml #46
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
name: SCSS Lint, Compile, and Package | |
on: | |
push: | |
branches: | |
- develop | |
pull_request: | |
branches: | |
- develop | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Set up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '20' | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Enable Corepack | |
run: corepack enable | |
- name: Install dependencies | |
run: cd private && yarn | |
- name: Compile SCSS to CSS | |
run: cd private && yarn build | |
- name: Delete Existing Release | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
(async () => { | |
const { Octokit } = await import("@octokit/rest"); | |
const octokit = new Octokit({ auth: process.env.GITHUB_TOKEN }); | |
const tagName = 'playground'; | |
const { owner, repo } = context.repo; | |
try { | |
// Get release by tag name | |
const release = await octokit.repos.getReleaseByTag({ | |
owner: owner, | |
repo: repo, | |
tag: tagName | |
}); | |
if (release) { | |
// Delete the release | |
await octokit.repos.deleteRelease({ | |
owner: owner, | |
repo: repo, | |
release_id: release.data.id | |
}); | |
console.log(`Deleted release with tag ${tagName}.`); | |
// Delete the tag | |
await octokit.git.deleteRef({ | |
owner: owner, | |
repo: repo, | |
ref: `tags/${tagName}` | |
}); | |
console.log(`Deleted tag ${tagName}.`); | |
} | |
} catch (error) { | |
if (error.status === 404) { | |
console.log(`Release with tag ${tagName} not found.`); | |
} else { | |
throw error; | |
} | |
} | |
})(); | |
- name: Archive production artifacts | |
run: zip -r humanity-theme-playground.zip wp-content/themes | |
- name: Upload artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: humanity-theme-playground-zip | |
path: humanity-theme-playground.zip | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.RELEASE2 }} | |
with: | |
tag_name: 'playground' # Adjust the tag name as needed | |
release_name: 'Playground Theme Release' | |
body: 'Release of the Humanity Theme for WordPress Playground' | |
draft: false | |
prerelease: false | |
- name: Upload Release Asset | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.RELEASE2 }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./humanity-theme-playground.zip | |
asset_name: humanity-theme-playground.zip | |
asset_content_type: application/zip | |
# add POMO file support |