Skip to content

Commit

Permalink
Fixed file names in CI. (#65)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexSkrypnyk authored Feb 27, 2024
1 parent f40dbbe commit b714d87
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 25 deletions.
34 changes: 20 additions & 14 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,10 @@ jobs:
name: Prepare test file.
command: |
export TEST_FILE="test-file--force-push--circleci--${CIRCLE_BRANCH//\//-}.txt"
echo "Deployment 1 for branch $CIRCLE_BRANCH" >> $TEST_FILE
echo "Deployment 1 for branch $CIRCLE_BRANCH" > $TEST_FILE
date "+%Y%m%d-%H%M%S" >> $TEST_FILE
cat $TEST_FILE
echo $TEST_FILE > $HOME/test-file.txt
- run:
name: Deployment 1
Expand All @@ -101,15 +103,16 @@ jobs:
DEPLOYED_BRANCH=$(sed -n 's/Remote branch://p' $HOME/report--mode--force-push.txt | sed 's/ //g')
echo "Deployed to $DEPLOYED_BRANCH"
echo
echo "See https://github.com/drevops/git-artifact-destination/blob/$DEPLOYED_BRANCH/$TEST_FILE"
echo "See https://github.com/drevops/git-artifact-destination/blob/$DEPLOYED_BRANCH/$(cat $HOME/test-file.txt)"
rm $HOME/report--mode--force-push.txt
- run:
name: Update the test file to simulate changes in the source repository.
command: |
export TEST_FILE="test-file--branch--circleci--${CIRCLE_BRANCH//\//-}.txt"
export TEST_FILE="test-file--force-push--circleci--${CIRCLE_BRANCH//\//-}.txt"
echo "Deployment 2 for branch $CIRCLE_BRANCH" >> $TEST_FILE
date "+%Y%m%d-%H%M%S" >> $TEST_FILE
cat $TEST_FILE
- run:
name: Deployment 2
Expand All @@ -125,7 +128,7 @@ jobs:
DEPLOYED_BRANCH=$(sed -n 's/Remote branch://p' $HOME/report--mode--force-push.txt | sed 's/ //g')
echo "Deployed to $DEPLOYED_BRANCH"
echo
echo "See https://github.com/drevops/git-artifact-destination/blob/$DEPLOYED_BRANCH/$TEST_FILE"
echo "See https://github.com/drevops/git-artifact-destination/blob/$DEPLOYED_BRANCH/$(cat $HOME/test-file.txt)"
# Demonstration of deployment in 'branch' mode.
# Note that by design, pushing into the same branch will result in the failure
Expand Down Expand Up @@ -155,8 +158,10 @@ jobs:
name: Prepare test file.
command: |
export TEST_FILE="test-file--branch--circleci--${CIRCLE_BRANCH//\//-}.txt"
echo "Deployment 1 for branch $CIRCLE_BRANCH" >> $TEST_FILE
echo "Deployment 1 for branch $CIRCLE_BRANCH" > $TEST_FILE
date "+%Y%m%d-%H%M%S" >> $TEST_FILE
cat $TEST_FILE
echo $TEST_FILE > $HOME/test-file.txt
- run:
name: Deployment 1
Expand All @@ -172,16 +177,9 @@ jobs:
DEPLOYED_BRANCH=$(sed -n 's/Remote branch://p' $HOME/report--mode--branch.txt | sed 's/ //g')
echo "Deployed to $DEPLOYED_BRANCH"
echo
echo "See https://github.com/drevops/git-artifact-destination/blob/$DEPLOYED_BRANCH/$TEST_FILE"
echo "See https://github.com/drevops/git-artifact-destination/blob/$DEPLOYED_BRANCH/$(cat $HOME/test-file.txt)"
rm $HOME/report--mode--branch.txt
- run:
name: Update the test file to simulate changes in the source repository.
command: |
export TEST_FILE="test-file--branch--circleci--${CIRCLE_BRANCH//\//-}.txt"
echo "Deployment 2 for branch $CIRCLE_BRANCH" >> $TEST_FILE
date "+%Y%m%d-%H%M%S" >> $TEST_FILE
- run:
name: Deployment 2 - same branch
command: |
Expand All @@ -194,6 +192,14 @@ jobs:
--debug \
&& { echo "Expected to fail as repeated pushes to the same branch are not allowed, but succeeded" >&2; exit 1; } || echo "Failed as expected"
- run:
name: Update the test file to simulate changes in the source repository.
command: |
export TEST_FILE="test-file--branch--circleci--${CIRCLE_BRANCH//\//-}.txt"
echo "Deployment 2 for branch $CIRCLE_BRANCH" > $TEST_FILE
date "+%Y%m%d-%H%M%S" >> $TEST_FILE
cat $TEST_FILE
- run:
name: Deployment 2 - new branch
command: |
Expand All @@ -208,7 +214,7 @@ jobs:
DEPLOYED_BRANCH=$(sed -n 's/Remote branch://p' $HOME/report--mode--branch.txt | sed 's/ //g')
echo "Deployed to $DEPLOYED_BRANCH"
echo
echo "See https://github.com/drevops/git-artifact-destination/blob/$DEPLOYED_BRANCH/$TEST_FILE"
echo "See https://github.com/drevops/git-artifact-destination/blob/$DEPLOYED_BRANCH/$(cat $HOME/test-file.txt)"
workflows:
version: 2
Expand Down
28 changes: 17 additions & 11 deletions .github/workflows/test-php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ jobs:
runs-on: ubuntu-latest

env:
GITHUB_BRANCH: ${{ github.head_ref }}
GITHUB_BRANCH: ${{ github.head_ref || github.ref_name }}

steps:
- name: Checkout code
Expand Down Expand Up @@ -116,8 +116,10 @@ jobs:
- name: Prepare test file.
run: |
export TEST_FILE="test-file--force-push--gha--${GITHUB_BRANCH//\//-}.txt"
echo "Deployment 1 for branch $GITHUB_BRANCH" >> $TEST_FILE
echo "Deployment 1 for branch $GITHUB_BRANCH" > $TEST_FILE
date "+%Y%m%d-%H%M%S" >> $TEST_FILE
cat $TEST_FILE
echo $TEST_FILE > $HOME/test-file.txt
- name: Deployment 1
run: |
Expand All @@ -132,14 +134,15 @@ jobs:
DEPLOYED_BRANCH=$(sed -n 's/Remote branch://p' $HOME/report--mode--force-push.txt | sed 's/ //g')
echo "Deployed to $DEPLOYED_BRANCH"
echo
echo "See https://github.com/drevops/git-artifact-destination/blob/$DEPLOYED_BRANCH/$TEST_FILE"
echo "See https://github.com/drevops/git-artifact-destination/blob/$DEPLOYED_BRANCH/$(cat $HOME/test-file.txt)"
rm $HOME/report--mode--force-push.txt
- name: Update the test file to simulate changes in the source repository.
run: |
export TEST_FILE="test-file--branch--gha--${GITHUB_BRANCH//\//-}.txt"
echo "Deployment 2 for branch $GITHUB_BRANCH" >> $TEST_FILE
export TEST_FILE="test-file--force-push--gha--${GITHUB_BRANCH//\//-}.txt"
echo "Deployment 2 for branch $GITHUB_BRANCH" > $TEST_FILE
date "+%Y%m%d-%H%M%S" >> $TEST_FILE
cat $TEST_FILE
- name: Deployment 2
run: |
Expand All @@ -154,7 +157,7 @@ jobs:
DEPLOYED_BRANCH=$(sed -n 's/Remote branch://p' $HOME/report--mode--force-push.txt | sed 's/ //g')
echo "Deployed to $DEPLOYED_BRANCH"
echo
echo "See https://github.com/drevops/git-artifact-destination/blob/$DEPLOYED_BRANCH/$TEST_FILE"
echo "See https://github.com/drevops/git-artifact-destination/blob/$DEPLOYED_BRANCH/$(cat $HOME/test-file.txt)"
# Demonstration of deployment in 'branch' mode.
# Note that by design, pushing into the same branch will result in the failure
Expand All @@ -166,7 +169,7 @@ jobs:
runs-on: ubuntu-latest

env:
GITHUB_BRANCH: ${{ github.head_ref }}
GITHUB_BRANCH: ${{ github.head_ref || github.ref_name }}

steps:
- name: Checkout code
Expand Down Expand Up @@ -213,8 +216,10 @@ jobs:
- name: Prepare test file.
run: |
export TEST_FILE="test-file--branch--gha--${GITHUB_BRANCH//\//-}.txt"
echo "Deployment 1 for branch $GITHUB_BRANCH" >> $TEST_FILE
echo "Deployment 1 for branch $GITHUB_BRANCH" > $TEST_FILE
date "+%Y%m%d-%H%M%S" >> $TEST_FILE
cat $TEST_FILE
echo $TEST_FILE > $HOME/test-file.txt
- name: Deployment 1
run: |
Expand All @@ -229,14 +234,15 @@ jobs:
DEPLOYED_BRANCH=$(sed -n 's/Remote branch://p' $HOME/report--mode--branch.txt | sed 's/ //g')
echo "Deployed to $DEPLOYED_BRANCH"
echo
echo "See https://github.com/drevops/git-artifact-destination/blob/$DEPLOYED_BRANCH/$TEST_FILE"
echo "See https://github.com/drevops/git-artifact-destination/blob/$DEPLOYED_BRANCH/$(cat $HOME/test-file.txt)"
rm $HOME/report--mode--branch.txt
- name: Update the test file to simulate changes in the source repository.
run: |
export TEST_FILE="test-file--branch--gha--${GITHUB_BRANCH//\//-}.txt"
echo "Deployment 2 for branch $GITHUB_BRANCH" >> $TEST_FILE
echo "Deployment 2 for branch $GITHUB_BRANCH" > $TEST_FILE
date "+%Y%m%d-%H%M%S" >> $TEST_FILE
cat $TEST_FILE
- name: Deployment 2 - same branch
run: |
Expand All @@ -262,4 +268,4 @@ jobs:
DEPLOYED_BRANCH=$(sed -n 's/Remote branch://p' $HOME/report--mode--branch.txt | sed 's/ //g')
echo "Deployed to $DEPLOYED_BRANCH"
echo
echo "See https://github.com/drevops/git-artifact-destination/blob/$DEPLOYED_BRANCH/$TEST_FILE"
echo "See https://github.com/drevops/git-artifact-destination/blob/$DEPLOYED_BRANCH/$(cat $HOME/test-file.txt)"

0 comments on commit b714d87

Please sign in to comment.