@@ -14,11 +14,17 @@ concurrency:
1414 cancel-in-progress : true
1515
1616jobs :
17- test :
17+ ci-cd :
1818 runs-on : ubuntu-latest
19+ permissions :
20+ contents : write
21+ packages : write
22+ id-token : write
1923 steps :
2024 - name : Checkout
2125 uses : actions/checkout@v4
26+ with :
27+ fetch-depth : 0
2228
2329 - name : Set up Node.js
2430 uses : actions/setup-node@v3
@@ -35,35 +41,16 @@ jobs:
3541 - name : Run tests
3642 run : npm test
3743
38- build-and-push :
39- needs : test
40- runs-on : ubuntu-latest
41- if : github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
42- permissions :
43- contents : write
44- packages : write
45- id-token : write
46- steps :
47- - name : Checkout
48- uses : actions/checkout@v4
49- with :
50- fetch-depth : 0
51-
52- - name : Set up Node.js
53- uses : actions/setup-node@v3
54- with :
55- node-version : ' 20'
56-
5744 - name : Get version from package.json
5845 id : version
46+ if : github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
5947 run : |
6048 VERSION=$(node -p "require('./package.json').version")
6149 echo "version=$VERSION" >> $GITHUB_OUTPUT
6250 echo "Detected version: $VERSION"
63- echo "Event: ${{ github.event_name }}"
64- echo "Ref: ${{ github.ref }}"
65-
51+
6652 - name : Tag Repository
53+ if : github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
6754 continue-on-error : true
6855 run : |
6956 NEW_TAG="v${{ steps.version.outputs.version }}"
@@ -87,16 +74,19 @@ jobs:
8774 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
8875
8976 - name : Set up Docker Buildx
77+ if : github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
9078 uses : docker/setup-buildx-action@v3
9179
9280 - name : Login to DockerHub
81+ if : github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
9382 uses : docker/login-action@v3
9483 with :
9584 registry : docker.io
9685 username : ${{ secrets.DOCKERHUB_USERNAME }}
9786 password : ${{ secrets.DOCKERHUB_TOKEN }}
9887
9988 - name : Build and push
89+ if : github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
10090 uses : docker/build-push-action@v5
10191 with :
10292 context : .
@@ -111,4 +101,5 @@ jobs:
111101 cache-to : type=gha,mode=max
112102
113103 - name : Image info
104+ if : github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
114105 run : docker manifest inspect docker.io/bigtimber/street-sweep:latest || true
0 commit comments