Update nighty build workflow (#51328)

This commit is contained in:
Adrian Moldovan 2024-09-16 10:11:15 +01:00 committed by GitHub
parent d397e39c75
commit 79b8a40157
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 32 additions and 25 deletions

View File

@ -4,23 +4,25 @@ on:
- cron: '0 0 * * *' # Run at 12 AM UTC. - cron: '0 0 * * *' # Run at 12 AM UTC.
workflow_dispatch: workflow_dispatch:
permissions: {} env:
SOURCE_REF: trunk
TARGET_REF: nightly
RELEASE_ID: 25945111
permissions: { }
jobs: jobs:
build: build:
if: github.repository_owner == 'woocommerce' if: github.repository_owner == 'woocommerce'
name: Nightly builds name: Nightly builds
strategy:
fail-fast: false
matrix:
build: [trunk]
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
permissions: permissions:
contents: write contents: write
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
with: with:
ref: ${{ matrix.build }} ref: ${{ env.SOURCE_REF }}
- name: Setup WooCommerce Monorepo - name: Setup WooCommerce Monorepo
uses: ./.github/actions/setup-woocommerce-monorepo uses: ./.github/actions/setup-woocommerce-monorepo
@ -31,26 +33,31 @@ jobs:
working-directory: plugins/woocommerce working-directory: plugins/woocommerce
run: bash bin/build-zip.sh run: bash bin/build-zip.sh
- name: Deploy nightly build - name: Upload nightly build
uses: WebFreak001/deploy-nightly@v1.1.0 uses: WebFreak001/deploy-nightly@46ecbabd7fad70d3e7d2c97fe8cd54e7a52e215b #v3.2.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with: with:
upload_url: https://uploads.github.com/repos/${{ github.repository }}/releases/25945111/assets{?name,label} token: ${{ secrets.GITHUB_TOKEN }}
release_id: 25945111 upload_url: https://uploads.github.com/repos/${{ github.repository }}/releases/${{ env.RELEASE_ID }}/assets{?name,label}
release_id: ${{ env.RELEASE_ID }}
asset_path: plugins/woocommerce/woocommerce.zip asset_path: plugins/woocommerce/woocommerce.zip
asset_name: woocommerce-${{ matrix.build }}-nightly.zip asset_name: woocommerce-${{ env.SOURCE_REF }}-nightly.zip
asset_content_type: application/zip asset_content_type: application/zip
max_releases: 1 max_releases: 1
update:
name: Update nightly tag commit ref - name: Update nightly tag commit ref
runs-on: ubuntu-20.04 uses: actions/github-script@v7
permissions:
contents: write
steps:
- name: Update nightly tag
uses: richardsimko/github-tag-action@v1.0.5
with: with:
tag_name: nightly github-token: ${{ secrets.GITHUB_TOKEN }}
env: script: |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} const sourceRef = process.env.SOURCE_REF;
const targetRef = process.env.TARGET_REF;
const branchData = await github.rest.repos.getBranch({
...context.repo,
branch: sourceRef,
});
await github.rest.git.updateRef({
...context.repo,
ref: `tags/${ targetRef }`,
sha: branchData.data.commit.sha,
});