Skip to content

Commit

Permalink
GHA take 4
Browse files Browse the repository at this point in the history
Fix .git directory being overwritten by build
  • Loading branch information
errose28 committed Dec 15, 2023
1 parent 094fd0f commit ed33cbe
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,33 @@ jobs:
runs-on: ubuntu-latest
steps:
# Check out the website source in the current working directory.
- name: "Checkout source branch"
uses: actions/checkout@v3
- name: "Checkout build branch"
- name: "Checkout source branch ${{ github.ref_name }}"
uses: actions/checkout@v3
with:
path: './build'
ref: 'asf-site-v2'
- name: "Build Website"
# Website source is mounted as volume, so the build output ends up in ./build outside of the container.
# This overwrites all files from the initial asf-site-v2 branch checkout, so we can just commit the result of this command.
path: 'src'
- name: "Build website"
# Website source is mounted as volume, so the build output ends up in ./src/build outside of the container.
run: |
docker compose run site pnpm run build
- name: "Checkout publish branch"
uses: actions/checkout@v3
with:
path: 'publish'
ref: 'asf-site-v2'
- name: "Commit changes"
working-directory: './build'
working-directory: 'publish'
run: |
echo "Deleting previous build from the branch $GITHUB_REF_NAME"
mv .git /tmp
rm -rf *
mv /tmp/.git .
echo "Committing new build to the branch $GITHUB_REF_NAME"
cp -R ../src/build/ .
git config --global user.name 'Github Actions'
git config --global user.email 'noreply@github.com'
git add .
git commit -a -m "[auto] Apply changes from HDDS-9225-website-v2 $GITHUB_SHA" || true
git commit -a -m "[auto] Apply changes from $GITHUB_REF_NAME $GITHUB_SHA" || true
git push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit ed33cbe

Please sign in to comment.