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: Update Release Files on Branch Push | ||
on: | ||
push: | ||
branches: | ||
- 'docker-action' | ||
env: | ||
RELEASE: please-ignore | ||
FILE_NAME: dizquetv-win-x64.exe | ||
jobs: | ||
update-release-files: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
- name: Checkout Repository | ||
uses: actions/checkout@v3 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
- name: Login to DockerHub | ||
uses: docker/login-action@v1 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
- name: Build and push | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: . | ||
file: Dockerfile-builder | ||
push: false | ||
tags: builder | ||
- name: Run dist docker | ||
run: | | ||
docker run -v ./dist:/home/node/app/dist builder | ||
- name: Get Release ID | ||
id: get_release | ||
run: | | ||
RELEASE_ID=$(curl -s \ | ||
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | ||
-H "Accept: application/vnd.github.v3+json" \ | ||
"https://api.github.com/repos/${{ github.repository }}/releases/tags/${{ env.RELEASE }}" \ | ||
| jq -r '.id') | ||
echo "RELEASE_ID=$RELEASE_ID" >> $GITHUB_ENV | ||
- name: Delete Old Asset (Optional) | ||
run: | | ||
ASSET_ID=$(curl -s \ | ||
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | ||
-H "Accept: application/vnd.github.v3+json" \ | ||
"https://api.github.com/repos/${{ github.repository }}/releases/$RELEASE_ID/assets" \ | ||
| jq -r '.[] | select(.name == "${{ env.FILE_NAME }}").id') | ||
if [ "$ASSET_ID" != "" ]; then | ||
curl -s \ | ||
-X DELETE \ | ||
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | ||
-H "Accept: application/vnd.github.v3+json" \ | ||
"https://api.github.com/repos/${{ github.repository }}/releases/assets/$ASSET_ID" | ||
fi | ||
- name: Upload New Asset | ||
uses: actions/upload-release-asset@v1 | ||
with: | ||
upload_url: "https://uploads.github.com/repos/${{ github.repository }}/releases/$RELEASE_ID/assets" | ||
asset_path: ./dist/${{ env.FILE_NAME }} | ||
asset_name: ${{ env.FILE_NAME }} | ||
asset_content_type: application/octet-stream | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |