@@ -15,6 +15,10 @@ concurrency:
1515 group : ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
1616 cancel-in-progress : true
1717
18+ env :
19+ DOCKERFILE : Dockerfile
20+ DOCKERHUB_USERNAME : humbugphp
21+
1822jobs :
1923 build-phar :
2024 runs-on : ubuntu-latest
7175 bin/php-scoper.phar
7276
7377 - name : Upload the PHAR artifact
74- if : github.event_name == 'release'
7578 uses : actions/upload-artifact@v3
7679 with :
7780 name : php-scoper-phar
9497 - name : Upload php-scoper.phar
9598 uses : softprops/action-gh-release@v1
9699 with :
97- token : ${{ secrets.PHP_SCOPER_GITHUB_TOKEN }}
100+ token : ${{ secrets.GITHUB_TOKEN }}
98101 files : |
99102 php-scoper.phar
100103 php-scoper.phar.asc
104+
105+ publish-docker-image :
106+ runs-on : ubuntu-latest
107+ name : Publish the Docker image
108+ needs :
109+ - build-phar
110+ steps :
111+ - name : Checkout
112+ uses : actions/checkout@v4
113+
114+ - uses : actions/download-artifact@v3
115+ with :
116+ name : php-scoper-phar
117+ path : .
118+
119+ # See https://github.com/actions/download-artifact#limitations
120+ # the permissions are not guaranteed to be preserved
121+ - name : Ensure PHAR is executable
122+ run : |
123+ chmod 755 php-scoper.phar
124+ mv -vf php-scoper.phar bin/php-scoper.phar
125+ ./bin/php-scoper.phar --ansi --version
126+
127+ - name : Set up QEMU
128+ uses : docker/setup-qemu-action@v3
129+
130+ - name : Set up Docker Buildx
131+ uses : docker/setup-buildx-action@v3
132+
133+ - name : Login to Docker Container Registry
134+ if : github.event_name == 'release'
135+ uses : docker/login-action@v3
136+ with :
137+ username : ${{ env.DOCKERHUB_USERNAME }}
138+ password : ${{ secrets.DOCKERHUB_TOKEN }}
139+
140+ - name : Setup the Docker (release) tag(s)
141+ if : github.event_name == 'release'
142+ # Selects a random value for $EOF as a delimiter, and sets the DOCKER_TAGS environment variable
143+ # as a multi-line environment variable.
144+ run : |
145+ EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
146+
147+ echo "DOCKER_TAGS<<$EOF" >> $GITHUB_ENV
148+ echo "${{ env.DOCKERHUB_USERNAME }}/php-scoper:${{ github.ref_name }}" >> $GITHUB_ENV
149+ echo "${{ env.DOCKERHUB_USERNAME }}/php-scoper:latest" >> $GITHUB_ENV
150+ echo "$EOF" >> $GITHUB_ENV
151+ echo "DOCKER_TEST_TAG=${{ env.DOCKERHUB_USERNAME }}/php-scoper:latest" >> $GITHUB_ENV
152+
153+ - name : Login to GitHub Container Registry
154+ if : github.event_name != 'release'
155+ uses : docker/login-action@v2
156+ with :
157+ registry : ghcr.io
158+ username : ${{ github.actor }}
159+ password : ${{ secrets.GITHUB_TOKEN }}
160+
161+ - name : Setup the Docker tag(s)
162+ if : github.event_name != 'release'
163+ run : |
164+ echo "DOCKER_TAGS=ghcr.io/humbugphp/php-scoper" >> $GITHUB_ENV
165+ echo "DOCKER_TEST_TAG=ghcr.io/humbugphp/php-scoper" >> $GITHUB_ENV
166+
167+ - name : Build and export to Docker
168+ uses : docker/build-push-action@v3
169+ with :
170+ context : .
171+ file : ${{ env.DOCKERFILE }}
172+ platforms : linux/amd64
173+ tags : ${{ env.DOCKER_TAGS }}
174+ load : true
175+
176+ - name : Test the (release) image
177+ run : docker run --rm ${{ env.DOCKER_TEST_TAG }} --version
178+
179+ - name : Build and push
180+ if : github.event_name == 'release'
181+ uses : docker/build-push-action@v3
182+ with :
183+ context : .
184+ file : ${{ env.DOCKERFILE }}
185+ platforms : linux/amd64
186+ tags : ${{ env.DOCKER_TAGS }}
187+ push : true
0 commit comments