current repo #23
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: Deploy website | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Get code | |
uses: actions/checkout@v3 | |
- name: Install dependencies | |
run: npm ci | |
- name: Lint code | |
run: npm run lint | |
- name: Test code | |
run: npm run test | |
build: | |
needs: test | |
runs-on: ubuntu-latest | |
steps: | |
- name: Get code | |
uses: actions/checkout@v3 | |
- name: Install dependencies | |
run: | | |
npm ci | |
git config -l | |
- name: Build website | |
run: npm run build | |
- name: Upload artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: dist-files | |
path: dist | |
# path: | | |
# dist | |
# package.json | |
pushtoanother: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- run: | | |
pwd | |
cd another | |
git config -l | |
date > generated.txt | |
git config user.name github-actions | |
git config user.email [email protected] | |
git add . | |
git commit -m "generated" | |
git config -l | |
git push | |
deploy: | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: dist-files | |
- name: Output contents | |
run: ls | |
- name: Deploy | |
run: | | |
echo "Deploying..." | |
# adding as per https://stackoverflow.com/questions/64270867/auth-error-trying-to-copy-a-repo-with-github-actions | |
# git config -l | grep 'http\..*\.extraheader' | cut -d= -f1 | xargs -L1 git config --unset-all | |
git clone https://github-actions[bot]:${{ secrets.GITHUB_TOKEN }}@github.com/sheetal-purple/another repo # clone repo to track history | |
ls -l | |
mv repo/.git . # move cloned git history to root | |
rm -rf repo | |
ls -l | |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
git config --local user.name "github-actions[bot]" | |
git add --force . | |
git commit -m "add contents of dist-files v${{ env.SPEC_VERSION }}" | |
git log | |
# relogin did not work as suggested in https://github.com/orgs/community/discussions/49745 | |
# echo "${{ secrets.GITHUB_TOKEN }}" > token.txt | |
# # Authorize GitHub CLI for the current repository and | |
# # create a pull-requests containing the updates. | |
# gh auth login --with-token < token.txt | |
git config -l | |
git tag -a v${{ env.SPEC_VERSION }} -m "Update v${{ env.SPEC_VERSION }}" | |
git push origin master --follow-tags --force | |
env: | |
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
SPEC_VERSION: 1.0.0 |